Example #1
0
 private void Awake()
 {
     navMeshAgent = GetComponent <NavMeshAgent>();
     enemySight   = GetComponent <EnemySight>();
     enemyWalk    = GetComponent <EnemyWalk>();
     animator     = spriteObject.GetComponent <Animator>();
 }
Example #2
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        head = GetComponent<EnemyHead>();
        body = this.transform.FindChild("Body");
        enemyWalk = GetComponent<EnemyWalk>();
        animator = GetComponent<Animator>();
        rigidBody = GetComponent<Rigidbody>();
        arenaLevel = (ArenaLevel)GameControl.control.level;

        //Load a blaster as our weapon
        GameObject turretCannon = GameControl.Spawn(Spawnable.Type.WEAPON_TURRET_CANNON, gameObject.transform.position, gameObject.transform.rotation);
        turretCannon.transform.parent = body;
        turretCannon.transform.localPosition = new Vector3(0f, 1f, 0f);
        weapon = turretCannon.GetComponent<Weapon>();
        turretCannon.GetComponent<TurretCannon>().waypointCollection = enemyWalk.waypointCollection;

        //Set our initial state to wander
        setCurrentState((int)State.WANDER);
        head.state = EnemyHead.State.IDLE;
        enemyWalk.state = EnemyWalk.State.IDLE;

        //Set our head to search
        List<GameObject> heroList = GameControl.control.level.GetHeroList();
        head.SearchForTargets(heroList);

    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();
     enemySight   = GetComponent <EnemySight>();
     enemyWalk    = GetComponent <EnemyWalk>();
     enemyState   = GetComponent <EnemyState>();
     animator     = spriteObject.GetComponent <Animator>();
 }
	// Use this for initialization
	void Start () {

		if (patrollEnemy) {
			patrollScript = EnemyObject.GetComponent<EnemyPatroll>();		
		}
		if (walkEnemy) {
			walkScript = EnemyObject.GetComponent<EnemyWalk>();		
		}

	}
Example #5
0
    private void InitStateMachine()
    {
        m_StateMachine = new StateMachine <Enemy>();

        enemyDie     = new EnemyDie(m_StateMachine);
        enemyFall    = new EnemyFall(m_StateMachine);
        enemyFlee    = new EnemyFlee(m_StateMachine);
        enemyIdle    = new EnemyIdle(m_StateMachine);
        enemyJumping = new EnemyJumping(m_StateMachine);
        enemyWalk    = new EnemyWalk(m_StateMachine);
    }
	void OnTriggerEnter2D(Collider2D theColl){

		if (theColl.gameObject.layer == LayerMask.NameToLayer("Ground") || theColl.gameObject.layer == LayerMask.NameToLayer("GrundNoPlayer")) {
			if (patrollEnemy) {
				patrollScript.setIsGrounded(true);		
			}
			if (walkEnemy) {
				walkScript = EnemyObject.GetComponent<EnemyWalk>();		
			}

		} 
	}
Example #7
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        head = GetComponent<EnemyHead>();
        body = this.transform.FindChild("Body");
        rigidBody = GetComponent<Rigidbody>();
        enemyWalk = GetComponent<EnemyWalk>();
        animator = GetComponent<Animator>();

        //Load a blaster as our weapon
        GameObject blasterWeapon = GameControl.Spawn(Spawnable.Type.WEAPON_BLASTER, gameObject.transform.position, gameObject.transform.rotation);
        blasterWeapon.transform.parent = body;
        weapon = blasterWeapon.GetComponent<Weapon>();
        weapon.weaponFireMode = 0;

        //Set our head to search
        List<GameObject> heroList = GameControl.control.level.GetHeroList();
        head.SearchForTargets(heroList);
    }
Example #8
0
 private void OnCollisionEnter2D(Collision2D col)
 {
     Debug.Log(col);
     if (col.transform.tag == Constants.Tags.Rocks)
     {
         if (col.transform.GetComponent <BombRock>() != null)
         {
             col.transform.GetComponent <BombRock>().Explode();
         }
         else
         {
             Destroy(col.gameObject);
             Destroy(gameObject);
         }
     }
     if (col.transform.tag == Constants.Tags.Enemy)
     {
         EnemyWalk temp = col.gameObject.GetComponent <EnemyWalk>();
         temp.hit(10);
     }
 }
Example #9
0
    private void Awake()
    {
        Initial();
        fsmManager     = new FSMManager((int)Data.AnimationCount.Max);
        animator       = transform.GetComponent <Animator>();
        control        = transform.GetComponent <CharacterController>();
        control.center = new Vector3(0, 1, 0);
        control.height = 2;
        control.radius = 0.23f;

        EnemyIdel enemyIdel = new EnemyIdel(animator);

        fsmManager.AddState(enemyIdel);
        EnemyWalk enemyWalk = new EnemyWalk(animator);

        fsmManager.AddState(enemyWalk);
        EnemyRun enemyRun = new EnemyRun(animator);

        fsmManager.AddState(enemyRun);
        EnemyAttack enemyAttack = new EnemyAttack(animator);

        fsmManager.AddState(enemyAttack);
    }