コード例 #1
0
    void HopputMove(Vector3 A, Vector3 B, HopputState state, float speedMultiplier = 1)
    {
        Vector3 dir = (B - A).normalized;

        dir.y = 0;
        Quaternion endRot = Quaternion.LookRotation(dir);

        transform.rotation  = endRot;
        transform.position += transform.forward * Time.deltaTime * speedAI * speedMultiplier;
        switch (state)
        {
        case HopputState.MOVE:
            if (DistanceBetween(A, B) < attackRange)
            {
                ChangeState(0.5f, HopputState.SHAKE);
            }
            break;

        case HopputState.JUMP:
            if (DistanceBetween(A, B) < 2)
            {
                ChangeState(0.5f, HopputState.LAND);
            }
            break;
        }
    }
コード例 #2
0
 void ChangeState(float timeBeforeStateChange, HopputState nextState)
 {
     if (gameTime > timeBeforeStateChange)
     {
         gameTime = 0;
         States   = nextState;
     }
 }
コード例 #3
0
    protected override void ActivateAbility()
    {
        gameTime += Time.deltaTime;
        if (healthAI < 1)
        {
            States = HopputState.DEATH;
        }
        switch (States)
        {
        case HopputState.IDLE:

            HopputAnim.SetBool("isMoving", false);
            ChangeState(5f, HopputState.MOVE);
            break;

        case HopputState.MOVE:
            HopputAnim.SetBool("isMoving", true);
            HopputMove(transform.position, player.position, States);
            break;

        case HopputState.SHAKE:
            HopputAnim.Play("HOP_SHAKEONLY");
            ChangeState(3f, HopputState.JUMP);
            lastPos = player.position;
            break;

        case HopputState.JUMP:
            HopputAnim.Play("HOP_JUMP");
            HopputMove(transform.position, lastPos, States, 2f);

            break;

        case HopputState.LAND:
            HopputAnim.Play("HOP_LAND");
            if (hasLanded)
            {
                ExplosionForce(transform.position, 5);
            }
            HopputAnim.StopPlayback();
            States = HopputState.IDLE;
            break;

        case HopputState.RECOIL:
            HopputAnim.Play("HOP_RECOIL");
            ChangeState(0.5f, HopputState.IDLE);
            HopputAnim.StopPlayback();
            break;

        case HopputState.DEATH:
            HopputAnim.Play("HOP_DEATH");

            break;
        }
    }
コード例 #4
0
ファイル: NewHopputAI.cs プロジェクト: Darylcxz/ANIMA-FYP
 protected override void ActivateAbility()
 {
     gameTime += Time.deltaTime;
     if(healthAI < 1)
     {
         States = HopputState.DEATH;
     }
     switch (States)
     {
         case HopputState.IDLE:
             
             HopputAnim.SetBool("isMoving", false);
             ChangeState(5f, HopputState.MOVE);
             break;
         case HopputState.MOVE:
             HopputAnim.SetBool("isMoving", true);
             HopputMove(transform.position,player.position,States);
             break;
         case HopputState.SHAKE:
             HopputAnim.Play("HOP_SHAKEONLY");
             ChangeState(3f, HopputState.JUMP);
             lastPos = player.position;
             break;
         case HopputState.JUMP:
             HopputAnim.Play("HOP_JUMP");
             HopputMove(transform.position,lastPos,States,2f);
             
             break;
         case HopputState.LAND:
             HopputAnim.Play("HOP_LAND");
             if(hasLanded)
             {
                 ExplosionForce(transform.position, 5);
             }
             HopputAnim.StopPlayback();
             States = HopputState.IDLE;
             break;
         case HopputState.RECOIL:
             HopputAnim.Play("HOP_RECOIL");
             ChangeState(0.5f, HopputState.IDLE);
             HopputAnim.StopPlayback();
             break;
         case HopputState.DEATH:
             HopputAnim.Play("HOP_DEATH");
          
             break;
     }
 }
コード例 #5
0
ファイル: HopputScript.cs プロジェクト: Darylcxz/ANIMA-FYP
    protected override void ActivateAbility()
    {
        currentTargetPosition = player.transform.position;

        switch (hopState)
        {
        case HopputState.IDLE:
            if (timerThing > 3)
            {
                timerThing = 0;
                hopState   = HopputState.MOVE;
                HopputAnim.SetInteger("AnimState", 1);
            }
            break;

        case HopputState.MOVE:
            MoveTowardsTarget();
            //maybe make it roam instead?
            if (playerDist < jumpRange)
            {
                hopState   = HopputState.SHAKE;
                timerThing = 0;
                HopputAnim.SetInteger("AnimState", 2);
            }
            break;

        case HopputState.SHAKE:
            //shake anim
            if (timerThing > 3)
            {
                hopState   = HopputState.ATTACK;
                timerThing = 0;
                HopputAnim.SetInteger("AnimState", 4);
            }
            break;

        case HopputState.ATTACK:
            //attack anim
            AISpeed = 5f;
            MoveTowardsTarget();
            if (timerThing > 1f)
            {
                Debug.Log(isGrounded() + " = grounded");
                if (isGrounded())
                {
                    Explosion(transform.position, 50);
                    timerThing = 0;
                    hopState   = HopputState.IDLE;
                    AISpeed    = 1f;
                    HopputAnim.SetInteger("AnimState", 0);
                }
            }

            break;

        case HopputState.RECOIL:
            //hurt anim
            if (timerThing > 5)
            {
                hopState   = HopputState.MOVE;
                timerThing = 0;
                HopputAnim.SetInteger("AnimState", 1);
            }
            break;
        }
    }
コード例 #6
0
ファイル: HopputScript.cs プロジェクト: Darylcxz/ANIMA-FYP
	protected override void ActivateAbility()
	{
		
		currentTargetPosition = player.transform.position;

		switch (hopState)
		{
 			case HopputState.IDLE:
				if (timerThing > 3)
				{
					timerThing = 0;
					hopState = HopputState.MOVE;
					HopputAnim.SetInteger("AnimState", 1);
				}
				break;
			case HopputState.MOVE:
				MoveTowardsTarget();
				//maybe make it roam instead?
				if (playerDist < jumpRange)
				{
					hopState = HopputState.SHAKE;
					timerThing = 0;
					HopputAnim.SetInteger("AnimState", 2);
				}
				break;
			case HopputState.SHAKE:
				//shake anim
				if (timerThing > 3)
				{
					hopState = HopputState.ATTACK;
					timerThing = 0;
					HopputAnim.SetInteger("AnimState", 4);
				}
				break;
			case HopputState.ATTACK:
				//attack anim
				AISpeed = 5f;
				MoveTowardsTarget();
				if (timerThing > 1f)
				{
					Debug.Log(isGrounded() + " = grounded");
					if (isGrounded())
					{
						Explosion(transform.position, 50); 
						timerThing = 0;
						hopState = HopputState.IDLE;
						AISpeed = 1f;
						HopputAnim.SetInteger("AnimState", 0);
					}
				}
				
				break;
			case HopputState.RECOIL:
				//hurt anim
				if (timerThing > 5)
				{
					hopState = HopputState.MOVE;
					timerThing = 0;
					HopputAnim.SetInteger("AnimState", 1);
				}
				break;

		}

	}
コード例 #7
0
ファイル: NewHopputAI.cs プロジェクト: Darylcxz/ANIMA-FYP
    void HopputMove( Vector3 A,Vector3 B,HopputState state, float speedMultiplier = 1)
    {
        Vector3 dir = (B - A).normalized;
        dir.y = 0;
        Quaternion endRot = Quaternion.LookRotation(dir);
        transform.rotation = endRot;
        transform.position += transform.forward * Time.deltaTime * speedAI * speedMultiplier;
        switch(state)
        {
            case HopputState.MOVE:
                if(DistanceBetween(A,B) < attackRange)
                {
                    ChangeState(0.5f, HopputState.SHAKE);
                }
                break;
            case HopputState.JUMP:
                if(DistanceBetween(A,B) < 2)
                {
                    ChangeState(0.5f, HopputState.LAND);
                }
                break;
        }

    }
コード例 #8
0
ファイル: NewHopputAI.cs プロジェクト: Darylcxz/ANIMA-FYP
 void ChangeState(float timeBeforeStateChange, HopputState nextState)
 {
     if(gameTime > timeBeforeStateChange)
     {
         gameTime = 0;
         States = nextState;
     }
 }