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);
        }
Beispiel #2
0
 void Start()
 {
     machine = new FSMMachineTest();
     state1  = new FSMState1("state1", machine);
     state2  = new FSMState2("state2", machine);
     machine.AddState(state1);
     machine.AddState(state2);
     machine.GotoState("state1");
 }