Ejemplo n.º 1
0
        /// <summary>
        /// Sets up all the states and transitions.
        /// </summary>
        protected virtual void SetUpAnimations()
        {
            DebugUtils.AssertNotNull(Data);
            CharacterData data = Data.As <CharacterData>();

            DebugUtils.AssertNotNull(data);

            // Checks that we have declared at most the same number of enum behaviours as we have animations.
            // If NumAnimations is larger than data.AnimationInfo.Count, it means we have not loaded enough animations for all our behaviours.
            Debug.Assert(data.AnimationInfo.Count >= NumBehaviours);

            StateMachine = new StateMachine(this, NumBehaviours);

            foreach (string animationDataAsset in data.AnimationInfo)
            {
                AnimationModule animation = new AnimationModule();
                animation.LoadContent();

                Debug.Assert(!Animations.ContainsKey(animationDataAsset));
                Animations.Add(animationDataAsset, animation);
            }

            CreateState("Idle", (uint)CharacterBehaviours.kIdle);
            CreateState("Death", (uint)CharacterBehaviours.kDeath);

            StateMachine.StartingState = (uint)CharacterBehaviours.kIdle;
        }
Ejemplo n.º 2
0
        public State(uint stateID, AnimationModule animation)
        {
            StateID   = stateID;
            Animation = animation;
            IsGlobal  = animation.IsGlobal;

            Transitions = new List <Transition>();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a state to this state machine.  This function takes care of global states and ID checks.
        /// Should not really be used - instead use Character function 'CreateState' - it is much nicer and tidier.
        /// </summary>
        /// <param name="state"></param>
        public void CreateState(uint id, AnimationModule animation)
        {
            // This is a check to make sure that we are adding the states in the order they are declared in the enum.
            // If this doesn't occur, the states will be mixed up and all hell will break loose.
            Debug.Assert(id == currentAddedStates);

            State state = new State(id, animation);

            States[currentAddedStates] = state;
            currentAddedStates++;

            // If our state is global, add it to our list
            if (state.IsGlobal)
            {
                GlobalStates.Add(state);
            }
        }
Ejemplo n.º 4
0
 public AnimatedGameObject(Vector2 localPosition, string animationDataAsset) :
     base(localPosition, animationDataAsset)
 {
     UsesCollider    = false;
     AnimationModule = AddModule(new AnimationModule());
 }