public void TriggerTransition(WizardFSMState.StateEnum newState, EntityId targetEntityId, Vector3 targetPosition)
        {
            if (npcWizard == null)
            {
                Debug.LogError("Trying to change state without authority.");
                return;
            }

            if (IsValidTransition(newState))
            {
                Data.currentState   = newState;
                Data.targetEntityId = targetEntityId;
                Data.targetPosition = targetPosition.FlattenVector().ToVector3f();

                var update = new NPCWizard.Update();
                update.SetCurrentState(Data.currentState);
                update.SetTargetEntityId(Data.targetEntityId);
                update.SetTargetPosition(Data.targetPosition);
                npcWizard.Send(update);

                TransitionTo(newState);
            }
            else
            {
                Debug.LogErrorFormat("NPCWizard: Invalid transition from {0} to {1} detected.", Data.currentState, newState);
            }
        }
Exemple #2
0
        private void Idle()
        {
            var enemyTeamId = GetRandomEnemyTeamId();

            if (enemyTeamId >= 0)
            {
                Coordinates approximateHQPosition = cachedTeamHqCoordinates[enemyTeamId];
                approximateHQPosition.X += -SimulationSettings.HQSpawnRadius / 2 + SimulationSettings.SpawnOffsetFactor * random.NextDouble();
                approximateHQPosition.Z += -SimulationSettings.HQSpawnRadius / 2 + SimulationSettings.SpawnOffsetFactor * random.NextDouble();

                NavigateToPosition(approximateHQPosition);

                wizard.Send(new NPCWizard.Update()
                            .SetCurrentState(WizardFSMState.StateEnum.MOVING_TO_POSITION)
                            .SetTargetEntity(EntityId.InvalidEntityId));
            }
        }