Ejemplo n.º 1
0
    public override void Exit()
    {
        // Update active Child Count.
        PlayerChildFSM.IncrementActiveChildCount();

        // Unhide the object, enabling the sprite and colliders, etc.
        m_pcFSM.rigidbody2D.isKinematic = false;
        m_pcFSM.collider2D.enabled      = true;
        m_pcFSM.spriteRen.enabled       = true;

        // Reset State.
        m_bIsCalledFromPool = false;
    }
Ejemplo n.º 2
0
    void Awake()
    {
        // does the pool exist yet
        if (s_playerChildFSMPool == null)
        {
            // lazy initialize it
            s_playerChildFSMPool = new PlayerChildFSM[Constants.s_nPlayerMaxChildCount];
            s_playerChildStatus  = new pcStatus[Constants.s_nPlayerMaxChildCount];
            s_nPoolPointerIndex  = 0;
            s_nActiveChildCount  = 0;

            s_childrenInRightNode = new int[] { -1 };
            s_childrenInLeftNode  = new int[] { -1 };
            s_childrenInAttack    = new int[] { -1 };
        }
        // add myself
        s_playerChildFSMPool[s_nPoolPointerIndex] = this;
        s_playerChildStatus[s_nPoolPointerIndex]  = pcStatus.DeadState;
        m_nPoolIndex = s_nPoolPointerIndex;
        s_nPoolPointerIndex++;


        // Cache components
        rigidbody2D   = GetComponent <Rigidbody2D>();
        collider2D    = GetComponent <CircleCollider2D>();
        spriteRen     = GetComponent <SpriteRenderer>();
        m_AudioSource = GetComponent <AudioSource>();

        // Set up the m_statesDictionary.
        m_statesDictionary = new Dictionary <PCState, IPCState>();
        m_statesDictionary.Add(PCState.Avoid, new PC_AvoidState(this));
        m_statesDictionary.Add(PCState.ChargeChild, new PC_ChargeChildState(this));
        m_statesDictionary.Add(PCState.ChargeMain, new PC_ChargeMainState(this));
        m_statesDictionary.Add(PCState.Dead, new PC_DeadState(this));
        m_statesDictionary.Add(PCState.Defend, new PC_DefendState(this));
        m_statesDictionary.Add(PCState.Idle, new PC_IdleState(this));


        PlayerChildFSM.IncrementActiveChildCount();
        // Change to dead state.
        m_currentState = m_statesDictionary[PCState.Dead];
        m_currentState.Enter();
        m_currentEnumState = PCState.Dead;
    }