Извините, ничего не найдено.

Не расстраивайся! Лучше выпей чайку!
Регистрация
Справка
Календарь

Вернуться   forum.boolean.name > Программирование игр для компьютеров > С#

С# Средство разработки на платформе .Net

Ответ
 
Опции темы
Старый 15.09.2015, 11:14   #1
SOmar
AnyKey`щик
 
Регистрация: 15.09.2015
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Сообщение из C++ в C#

Помогите перевести с С++ на С#
class FormationManager:

# Holds the assignment of a single character to a slot
struct SlotAssignment:      Вот это я понял
character
slotNumber

# Holds a list of slots assignments.
slotAssignments         Это скорее всего List<>

# Holds a Static structure (i.e., position and orientation)
# representing the drift offset for the currently filled
# slots.
driftOffset            Это переменная типа трансформ или вектор хотя не  уверен

# Holds the formation pattern
pattern                                     

# Updates the assignment of characters to slots
def updateSlotAssignments():

# A very simply assignment algorithm: we simply go through
# each assignment in the list and assign sequential slot
# numbers
for i in 0..slotAssignments.length():        Я так понял это цикл for но как то 
slotAssignments
[i].slotNumber i           странно записан

# Update the drift offset
driftOffset pattern.getDriftOffset(slotAssignments)

# Add a new character to the first available slot. Returns
# false if no more slots are available.
def addCharacter(character):

# Find out how many slots we have occupied
occupiedSlots slotAssignments.length()

# Check if the pattern supports more slots
if pattern.supportsSlots(occupiedSlots 1):

# Add a new slot assignment
slotAssignment = new SlotAssignment()
slotAssignment.character character
slotAssignments
.append(slotAssignment)

# Update the slot assignments and return success
updateSlotAssignments()
return 
true

# Otherwise we’ve failed to add the character
return false

# Removes a character from its slot.
def removeCharacter(character):

# Find the character’s slot
slot charactersInSlots.find(character)

# Make sure we’ve found a valid result
if slot in 0..slotAssignments.length():

# Remove the slot
slotAssignments.removeElementAt(slot)

# Update the assignments
updateSlotAssignments()

# Write new slot locations to each character
def updateSlots():

# Find the anchor point
anchor getAnchorPoint()

# Get the orientation of the anchor point as a matrix
orientationMatrix anchor.orientation.asMatrix()

# Go through each character in turn
for i in 0..slotAssignments.length():

# Ask for the location of the slot relative to the
# anchor point. This should be a Static structure
relativeLoc pattern.getSlotLocation(slotAssignments[i].slotNumber)

#Transform it by the anchor point’s position and
#orientation
location = new Static()
location.position relativeLoc.position orientationMatrix anchor.position
location
.orientation anchor.orientation relativeLoc.orientation

#    And add the drift component location.position -= driftOffset.position location.orientation -= driftOffset.orientation

#    Write the static to the character slotAssignments[i].character.setTarget(location) 
(Offline)
 
Ответить с цитированием
Старый 15.09.2015, 11:47   #2
Andvrok
Бывалый
 
Регистрация: 26.07.2009
Сообщений: 785
Написано 362 полезных сообщений
(для 995 пользователей)
Ответ: из C++ в C#

Это не С++
На питон похоже, но я не эксперт.

В любом случае, здесь нет объявлений типов "formation pattern" и "Static", это просто огрызок кода, выдранный из контекста.

UPD: Нашёл эту книжку (Artificial Intelligence for Games), цитирую:

Alghoritms in this book are presented in pseudo-code for brevity and simplicity.
Так что это даже не питон.
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
SOmar (15.09.2015)
Старый 15.09.2015, 16:48   #3
SOmar
AnyKey`щик
 
Регистрация: 15.09.2015
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Ответ: из C++ в C#

Сообщение от Andvrok Посмотреть сообщение
Это не С++
На питон похоже, но я не эксперт.

В любом случае, здесь нет объявлений типов "formation pattern" и "Static", это просто огрызок кода, выдранный из контекста.

UPD: Нашёл эту книжку (Artificial Intelligence for Games), цитирую:



Так что это даже не питон.
Понятно! В любом случаи придумал уже свой алгоритм
(Offline)
 
Ответить с цитированием
Ответ


Опции темы

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


Часовой пояс GMT +4, время: 02:39.


vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot
Style crйe par Allan - vBulletin-Ressources.com