Beispiel #1
0
        private void OnTriggerEnter(Collider other)
        {
            player = other.gameObject;
            treeState.Send(new TreeState.Update().SetPopulation(treeState.Data.population + 1));
            Coordinates targetCoord  = countries[UnityEngine.Random.Range(0, 9)];
            Vector3     targetVector = new Vector3((float)targetCoord.X, (float)targetCoord.Y, (float)targetCoord.Z);

            targetVector = (targetVector - player.transform.position).normalized;


            player.gameObject.GetComponent <IndividualMovement>().Movement = targetVector;
        }
Beispiel #2
0
        public void TriggerTransition(TreeFSMState newState)
        {
            if (tree == null)
            {
                Debug.LogError("Trying to change state without authority.");
                return;
            }

            if (IsValidTransition(newState))
            {
                Data.currentState = newState;

                var update = new TreeState.Update();
                update.SetCurrentState(Data.currentState);
                tree.Send(update);

                TransitionTo(newState);
            }
            else
            {
                Debug.LogErrorFormat("Tree: Invalid transition from {0} to {1} detected.", Data.currentState, newState);
            }
        }