コード例 #1
0
 //a function to change the enemy child state and make the appropriate changes to the enemy child cell
 public void ChangeState(ECState _state)
 {
     m_CurrentState.Exit();
     m_CurrentState = m_StatesDictionary[_state];
     m_CurrentEnum = _state;
     m_CurrentState.Enter();
 }
コード例 #2
0
 //a function to change the enemy child state and make the appropriate changes to the enemy child cell
 public void ChangeState(ECState _state)
 {
     m_CurrentState.Exit();
     m_CurrentState = m_StatesDictionary[_state];
     m_CurrentEnum  = _state;
     m_CurrentState.Enter();
 }
コード例 #3
0
    //
    void Start()
    {
        //Initialize the variables and data structure
        m_fRotationTarget   = Random.Range(0f, 360f);
        m_RandomRotateSpeed = new Vector3(0f, 0f, 0.85f);
        m_bRotateCW         = false;
        m_bRotateACW        = false;
        m_PMain             = GameObject.Find("Player_Cell");
        m_EMain             = GameObject.Find("Enemy_Cell");
        m_EMFSM             = m_EMain.GetComponent <EnemyMainFSM>();
        m_EMControl         = m_EMain.GetComponent <EMController>();
        m_Rigidbody2D       = GetComponent <Rigidbody2D>();
        m_ChildTransform    = transform;

        m_ChargeTarget     = null;
        m_StatesDictionary = new Dictionary <ECState, IECState>();

        m_AudioSource = GetComponent <AudioSource>();

        //Initialize the various states for the enemy child cell and added them into the dictionary
        m_StatesDictionary.Add(ECState.Idle, new ECIdleState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.Defend, new ECDefendState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.Avoid, new ECAvoidState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.Attack, new ECAttackState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.ChargeMain, new ECChargeMState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.ChargeChild, new ECChargeCState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.TrickAttack, new ECTrickAttackState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.Landmine, new ECMineState(this.gameObject, this));
        m_StatesDictionary.Add(ECState.Dead, new ECDeadState(this.gameObject, this));

        //initialize the current state for the enemy child cell
        m_CurrentState   = m_StatesDictionary[ECState.Dead];
        m_CurrentEnum    = ECState.Dead;
        m_CurrentCommand = MessageType.Empty;
        CurrentState.Enter();
    }
コード例 #4
0
    //
    void Start()
    {
        //Initialize the variables and data structure
        m_fRotationTarget = Random.Range(0f,360f);
        m_RandomRotateSpeed = new Vector3(0f,0f,0.85f);
        m_bRotateCW = false;
        m_bRotateACW = false;
        m_PMain = GameObject.Find("Player_Cell");
        m_EMain = GameObject.Find("Enemy_Cell");
        m_EMFSM = m_EMain.GetComponent<EnemyMainFSM>();
        m_EMControl = m_EMain.GetComponent<EMController>();
        m_Rigidbody2D = GetComponent<Rigidbody2D>();
        m_ChildTransform = transform;

        m_ChargeTarget = null;
        m_StatesDictionary = new Dictionary<ECState,IECState>();

        m_AudioSource = GetComponent<AudioSource>();

        //Initialize the various states for the enemy child cell and added them into the dictionary
        m_StatesDictionary.Add(ECState.Idle, new ECIdleState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Defend, new ECDefendState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Avoid, new ECAvoidState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Attack, new ECAttackState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.ChargeMain, new ECChargeMState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.ChargeChild, new ECChargeCState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.TrickAttack, new ECTrickAttackState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Landmine, new ECMineState(this.gameObject,this));
        m_StatesDictionary.Add(ECState.Dead, new ECDeadState(this.gameObject,this));

        //initialize the current state for the enemy child cell
        m_CurrentState = m_StatesDictionary[ECState.Dead];
        m_CurrentEnum = ECState.Dead;
        m_CurrentCommand = MessageType.Empty;
        CurrentState.Enter();
    }