public void Init(float animalAnimationSpeed, float animalMoveSpeed, int idxInTeam,
                         float animalAcceleration, float rotateSpeed)
        {
            this.animalAnimationSpeed = animalAnimationSpeed;
            this.moveSpeed            = animalMoveSpeed * 0.001f;
            this.moveSpeedBak         = this.moveSpeed;
            this.animalAccelerationMS = animalAcceleration * 0.001f;
            this.rotateSpeedMS        = rotateSpeed * 0.001f;
            this.idxInTeam            = idxInTeam;
            isMoving             = false;
            isPassedRoad         = false;
            isArrivedNextRoadPos = false;
            arrivedLastPos       = false;
            isRotateback         = false;
            isRotateForward      = false;
            rotateAngle          = 0f;
            waitFrameCount       = 0;

            //var a = roadModel.animalRoadSegment[roadModel.animalRoadSegment.Count - 1];
            //var b = roadModel.crossRoadRectArea[roadModel.animalRoadSegment.Count - 1].height;
            //Debug.LogError(a + b * Vector3.forward + Vector3.forward * standardAnimalBoxSize.z);
            if (fsm == null)
            {
                fsm = new FSMCrossRoadAnimal(this);
                fsm.AddState(new StateCrossRoadAnimalIdle((int)FSMCrossRoadAnimalState.Idle, fsm));
                fsm.AddState(new StateCrossRoadAnimalCrossRoad((int)FSMCrossRoadAnimalState.CrossRoad, fsm));
                fsm.AddState(new StateCrossRoadRunToEndPoint((int)FSMCrossRoadAnimalState.RunToEndPoint, fsm));
            }
            fsm.GotoState((int)FSMCrossRoadAnimalState.Idle);
            fsm.Run();

            DebugFile.GetInstance().MarkGameObject(mainGameObject, "Animal-{0}", idxInTeam);
        }
 public override void Active()
 {
     base.Active();
     Reset();
     followPath.Run();
     fsmMachine.Run();
 }
Exemplo n.º 3
0
        // Use this for initialization
        void Start()
        {
            fSMMachine = new FSMMachine <StateExample>("Example");
            fSMMachine.DefaultState = StateExample.LightOffOn;
            fSMMachine.AddStatus(StateExample.LightOffOn, new LightingSwitchOffState());
            fSMMachine.AddStatus(StateExample.LightColorSwitch, new LightingColorChangeState(Color.red));

            fSMMachine.Run();

            StartCoroutine(ChangeState());
        }