Ejemplo n.º 1
0
	private void E2_CheckPlayerPosition()
	{
		if(E_FindPlayer)
		E_PlayerPosition = E_FindPlayer.GetComponent<Transform>().position;

		//Debug.Log("faaaaaaaaaaaaaaaaaaaaaalse");

		//If the palyer is 8 units or less away from the enemy, and they're both at roughly the same Y position, the enemy stops moving and starts shooting
		if (Mathf.Abs(E_PlayerPosition.x - E_Transform.position.x) <= 8.0f && Mathf.Abs(E_PlayerPosition.y - E_Transform.position.y) <= 1.0f)
		{
			E_State = 2;
			E_StateChangeTimer = 1.0f;
			//Debug.Log("NAAANNIII");

			//The enemy flips to face the player
			if ((E_PlayerPosition.x - E_Transform.position.x <= 0) && Mathf.Abs(E_PlayerPosition.y - E_Transform.position.y) <= 1.0f && E_FacingRight == true)
			{

					//Debug.Log("Flipxxx");
					E_Flip();
				
			}
			else if ((E_PlayerPosition.x - E_Transform.position.x > 0) && Mathf.Abs(E_PlayerPosition.y - E_Transform.position.y) <= 1.0f && E_FacingRight == false)
			{
				
					//Debug.Log("Flipzzz");
					E_Flip();
				
			}

			if(E2_WindUpTimer>=0.0F)
			{
				E2_WindUpTimer -= Time.deltaTime;
			}

			if (E2_WindUpTimer <= 0.0F)
			{
				E2_Jump();
			}

		}
		else if (Mathf.Abs(E_PlayerPosition.x - E_Transform.position.x) >= 8.0f && Mathf.Abs(E_PlayerPosition.y - E_Transform.position.y) >= 1.0f)
		{
			E_State = 1;
			E2_WindUpTimer = 0.3f;

		}
		else
		{
			//Debug.Log("ElSSSEEEE");
			E_StateChangeTimer -= Time.deltaTime;
			if(E_StateChangeTimer<=0)
			{
				E_StateChangeTimer = 3.0f;
				E2_WindUpTimer = 0.3f;
				E_State = 1;
			}
		}

	}
Ejemplo n.º 2
0
    private void E1_CheckPlayerPosition()
    {
        if (E_FindPlayer)
        {
            E_PlayerPosition = E_FindPlayer.GetComponent <Transform>().position;
        }

        //If the palyer is 4 units or less away from the enemy, and they're both at roughly the same Y position, the enemy stops moving and starts shooting
        if (Mathf.Abs(E_PlayerPosition.x - E_Transform.position.x) <= 8.0f && Mathf.Abs(E_PlayerPosition.y - E_Transform.position.y) <= 1.0f)
        {
            E_Speed = 0.0f;

            //The enemy flips to face the player
            if ((E_PlayerPosition.x - E_Transform.position.x <= 0) && E_FacingRight == true)
            {
                E_Flip();
            }
            else if ((E_PlayerPosition.x - E_Transform.position.x > 0) && E_FacingRight == false)
            {
                E_Flip();
            }

            if (E1_WindUpTimer <= 0)
            {
                if (Time.time > E1_NextFire)
                {
                    E1_NextFire = Time.time + E1_FireRate;
                    E1_Fire();
                }
            }
            else
            {
                E1_WindUpTimer -= Time.deltaTime;
            }
        }
        else
        {
            E_Speed        = 2.0f;
            E1_WindUpTimer = 0.2f;
        }
    }