Example #1
0
 // Update is called once per frame
 void Update()
 {
     // Turn Left
     if(movement.isLeft && !jelly.isHurt && !movement.thrust && !movement.increasing && currentAnim != anim.moveleft) {
         currentAnim = anim.moveleft;
         mySprite.Play("moveleft");
     }
     // Turn Right
     if(movement.isRight && !jelly.isHurt && !movement.thrust && !movement.increasing && currentAnim != anim.moveleft) {
         currentAnim = anim.moveright;
         mySprite.Play("moveright");
     }
     // Is Increasing
     if(!movement.isLeft && !movement.isRight && !jelly.isHurt && movement.increasing && !movement.thrust && currentAnim != anim.thrust) {
         currentAnim = anim.thrust;
         mySprite.Play("thrust");
     }
     // Is Hurt
     if(jelly.isHurt && currentAnim != anim.hurt) {
         currentAnim = anim.hurt;
         mySprite.Play("hurt");
     }
     // Reset Animation
     if(!movement.isLeft && !movement.isRight && !movement.increasing && !jelly.isHurt && currentAnim != anim.idle) {
         currentAnim = anim.idle;
         mySprite.Play("idle");
     }
 }
Example #2
0
 public void OnColissionEnter(Collision collision)
 {
     Debug.Log("Colidiu!");
     Dialogos.exibirOld = true;
     mover       = false;
     currentAnim = anim.andandoBaixo;
 }
    void Update()
    {
        // run left
        if (((character.isLeft == true) || (character.isUp == true)) && (currentAnim != anim.WalkLeft))
        {
            currentAnim = anim.WalkLeft;
            playerSprite.Play("run");
            spriteParent.localScale = new Vector3(-1,1,1);
        }

        // stand left
        if((character.isLeft == false) && (character.isUp == false) && (character.isDown == false) && (currentAnim != anim.StandLeft) && (character.facingDir == Character.facing.Left))
        {
            currentAnim = anim.StandLeft;
            playerSprite.Play("stand"); // stand left
            spriteParent.localScale = new Vector3(-1,1,1);
        }

        // run right
        if(((character.isRight == true) || (character.isDown == true)) && (currentAnim != anim.WalkRight))
        {
            currentAnim = anim.WalkRight;
            playerSprite.Play("run");
            spriteParent.localScale = new Vector3(1,1,1);
        }

        // stand right
        if((character.isRight == false) && (character.isUp == false) && (character.isDown == false) && (currentAnim != anim.StandRight) && (character.facingDir == Character.facing.Right))
        {
            currentAnim = anim.StandRight;
            playerSprite.Play("stand"); // stand right
            spriteParent.localScale = new Vector3(1,1,1);
        }
    }
Example #4
0
    public void updateMovement()
    {
        float xAtual = 0;

        if (direcao)
        {
            xAtual = -3;
            if (currentAnim != anim.andandoEsquerda)
            {
                currentAnim = anim.comecoAndarEsquerda;
            }
        }
        else
        {
            xAtual = 3;

            if (currentAnim != anim.andandoDireita)
            {
                currentAnim = anim.comecoAndarDireita;
            }
        }

        Vector2 movement = new Vector2(xAtual * 5, 0);

        movement *= Time.deltaTime * moveSpeed;

        mySprite.position = Vector3.Lerp(mySprite.position, movement + mySprite.position, Time.time);
        //mySprite.position += movement;
    }
Example #5
0
 void OnTriggerEnter(Collider otherObj)
 {
     Debug.Log("Colidiu!");
     Dialogos.exibirBoy = true;
     mover       = false;
     currentAnim = anim.andandoBaixo;
 }
Example #6
0
 // Update is called once per frame
 void Update()
 {
     // If the fish is facing left and the jellyfish is far, play an idle animation
     if(fish.isLeft && !fish.isRight && fish.idle && !fish.near && !fish.veryNear && currentAnim != anim.IdleLeft) {
         currentAnim = anim.IdleLeft;
         mySprite.Play("idleleft");
     }
     // If the fish is facing left and the jellyfish is near, play a near animation
     if(fish.isLeft && !fish.isRight && !fish.idle && fish.near && !fish.veryNear && currentAnim != anim.NearLeft) {
         currentAnim = anim.NearLeft;
         mySprite.Play("nearleft");
     }
     // If the fish is facing left and the jellyfish is very near, play an eating animation
     if(fish.isLeft && !fish.isRight && !fish.idle && !fish.near && fish.veryNear && currentAnim != anim.EatLeft) {
         currentAnim = anim.EatLeft;
         mySprite.Play("eatleft");
     }
     // Facing right, jellyfish is far
     if(!fish.isLeft && fish.isRight && fish.idle && !fish.near && !fish.veryNear && currentAnim != anim.IdleLeft) {
         currentAnim = anim.IdleRight;
         mySprite.Play("idleright");
     }
     // Facing right, jellyfish is near
     if(!fish.isLeft && fish.isRight && !fish.idle && fish.near && !fish.veryNear && currentAnim != anim.NearLeft) {
         currentAnim = anim.NearRight;
         mySprite.Play("nearright");
     }
     // Facing right, jellyfish is very near
     if(!fish.isLeft && fish.isRight && !fish.idle && !fish.near && fish.veryNear && currentAnim != anim.EatLeft) {
         currentAnim = anim.EatRight;
         mySprite.Play("eatright");
     }
 }
Example #7
0
		void Update()
		{
			
		
				if(mover)
				{
					if(passos>100)
					{
						if(direcao)
							currentAnim = anim.ParouEsquerda;
						else
							currentAnim = anim.ParouDireita;
						
						
						direcao = !direcao;	
						passos = -20;		
					
					}			
					passos++;										
								
					updateMovement();
		
				}
			
		}
Example #8
0
		public void updateMovement()
		{
			
			float xAtual= 0;
			
			if(direcao)
			{
				xAtual = -3;
			if(currentAnim!= anim.andandoEsquerda)
	  		     currentAnim = anim.comecoAndarEsquerda;
				
			}else				
			{ 
				xAtual = 3;
				
			if(currentAnim!= anim.andandoDireita)
	  		     currentAnim = anim.comecoAndarDireita;
			}
									
			Vector2 movement = new Vector2(xAtual*5, 0);			
			movement *= Time.deltaTime*moveSpeed;				
								
			mySprite.position = Vector3.Lerp(mySprite.position,movement+mySprite.position,Time.time);					
			//mySprite.position += movement;	
			
								
			
		}		
Example #9
0
    void Update()
    {
        // if the game is over, don't bother updating any animations
        if (xa.gameOver == true)
        {
            return;
        }

        // run left
        if (character.currentInputState == Character.inputState.WalkLeft && character.grounded == true && currentAnim != anim.WalkLeft)
        {
            currentAnim = anim.WalkLeft;
            _animator.SetInteger(_animState, 1);
            _transform.localScale = new Vector3(1, 1, 1);
        }

        // stand left
        if (character.currentInputState != Character.inputState.WalkLeft && character.grounded == true && currentAnim != anim.StandLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.StandLeft;
            _animator.SetInteger(_animState, 0);
            _transform.localScale = new Vector3(1, 1, 1);
        }

        // run right
        if (character.currentInputState == Character.inputState.WalkRight && character.grounded == true && currentAnim != anim.WalkRight)
        {
            currentAnim = anim.WalkRight;
            _animator.SetInteger(_animState, 1);
            _transform.localScale = new Vector3(-1, 1, 1);
        }

        // stand right
        if (character.currentInputState != Character.inputState.WalkRight && character.grounded == true && currentAnim != anim.StandRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.StandRight;
            _animator.SetInteger(_animState, 0);
            _transform.localScale = new Vector3(-1, 1, 1);
        }

        // fall or jump left
        if (character.grounded == false && currentAnim != anim.FallLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.FallLeft;
            _animator.SetInteger(_animState, 2);
            _transform.localScale = new Vector3(1, 1, 1);
        }

        // fall or jump right
        if (character.grounded == false && currentAnim != anim.FallRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.FallRight;
            _animator.SetInteger(_animState, 2);
            _transform.localScale = new Vector3(-1, 1, 1);
        }
    }
Example #10
0
 public void animScaleDown()
 {
     //time = Mathf.Lerp(time, 8, 5);
     transform.localScale = Vector3.MoveTowards(transform.localScale, Vector3.one, time1 * Time.deltaTime);
     if (transform.localScale.x == 1f)
     {
         Anima = NullFunction;
         // transform.GetChild(0).gameObject.SetActive(true);
     }
 }
Example #11
0
 public void animPosDown()
 {
     //time = Mathf.Lerp(time, 8, 5);
     transform.localPosition = Vector3.MoveTowards(transform.localPosition, new Vector3(transform.localPosition.x, 0, 0), time1 * Time.deltaTime);
     if (transform.localPosition.y == 0)
     {
         Anima = NullFunction;
         // transform.GetChild(0).gameObject.SetActive(true);
     }
 }
Example #12
0
 public void animAlfa()
 {
     time = Mathf.Lerp(time, 3, 5);
     GetComponent <Image>().color = new Color(0, 0, 0, Startalpha += time * Time.deltaTime);
     if (GetComponent <Image>().color.a > 0.7f)
     {
         GetComponent <Image>().color = new Color(0, 0, 0, 0.7f);
         Anima = NullFunction;
         transform.GetChild(0).gameObject.SetActive(true);
     }
 }
Example #13
0
    void Start()
    {
        Camera.main.gameObject.GetComponent <Camera>().orthographicSize = 300;
        mySprite = GameObject.Find("PLAYER").GetComponent <OTAnimatingSprite>();


        Debug.Log(mySprite);

        currentAnim = anim.parado;

        theCamera = Camera.main.gameObject;
    }
Example #14
0
 public void animPosUp()
 {
     time = Mathf.Lerp(time, 1200, 5);
     transform.localPosition = Vector3.MoveTowards(transform.localPosition, new Vector3(transform.localPosition.x, target, 0), time * Time.deltaTime);
     if (transform.localPosition.y == target)
     {
         Anima = animPosDown;
         if (nextone != null)
         {
             nextone.gameObject.SetActive(true);
         }
     }
 }
Example #15
0
	void Start () {
		
		Camera.main.gameObject.GetComponent<Camera>().orthographicSize = 300;    
        mySprite = GameObject.Find("PLAYER").GetComponent<OTAnimatingSprite>();
		
		
		Debug.Log(mySprite);
		
		currentAnim = anim.parado;
		
		theCamera = Camera.main.gameObject; 
	
	}
Example #16
0
 public void animScaleUp()
 {
     time = Mathf.Lerp(time, 30, 5);
     transform.localScale = Vector3.MoveTowards(transform.localScale, Vector3.one * target, time * Time.deltaTime);
     if (transform.localScale.x == target)
     {
         Anima = animScaleDown;
         if (transform.childCount != 0)
         {
             transform.GetChild(0).gameObject.SetActive(true);
         }
     }
 }
Example #17
0
    void Update()
    {
        // run left
        if(character.currentInputState == Character.inputState.WalkLeft && character.grounded == true && currentAnim != anim.WalkLeft)
        {
            currentAnim = anim.WalkLeft;
            _animator.SetInteger(_animState, 1);
            _transform.localScale = new Vector3(1,1,1);
        }

        // stand left
        if(character.currentInputState != Character.inputState.WalkLeft && character.grounded == true && currentAnim != anim.StandLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.StandLeft;
            _animator.SetInteger(_animState, 0);
            _transform.localScale = new Vector3(1,1,1);
        }

        // run right
        if(character.currentInputState == Character.inputState.WalkRight && character.grounded == true && currentAnim != anim.WalkRight)
        {
            currentAnim = anim.WalkRight;
            _animator.SetInteger(_animState, 1);
            _transform.localScale = new Vector3(-1,1,1);
        }

        // stand right
        if(character.currentInputState != Character.inputState.WalkRight && character.grounded == true && currentAnim != anim.StandRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.StandRight;
            _animator.SetInteger(_animState, 0);
            _transform.localScale = new Vector3(-1,1,1);
        }

        // fall or jump left
        if(character.grounded == false && currentAnim != anim.FallLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.FallLeft;
            _animator.SetInteger(_animState, 2);
            _transform.localScale = new Vector3(1,1,1);
        }

        // fall or jump right
        if(character.grounded == false && currentAnim != anim.FallRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.FallRight;
            _animator.SetInteger(_animState, 2);
            _transform.localScale = new Vector3(-1,1,1);
        }
    }
    void Update()
    {
        if(xa.gameOver == true) return;

        // run left
        if(character.isLeft && character.grounded == true && currentAnim != anim.WalkLeft)
        {
            currentAnim = anim.WalkLeft;
            playerSprite.Play("run");
            spriteParent.localScale = new Vector3(-1,1,1);
        }
        if(!character.isLeft && character.grounded == true && currentAnim != anim.StandLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.StandLeft;
            playerSprite.Play("stand"); // stand left
            spriteParent.localScale = new Vector3(-1,1,1);
        }

        // run right
        if(character.isRight && character.grounded && currentAnim != anim.WalkRight)
        {
            currentAnim = anim.WalkRight;
            playerSprite.Play("run");
            spriteParent.localScale = new Vector3(1,1,1);
        }
        if(!character.isRight && character.grounded && currentAnim != anim.StandRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.StandRight;
            playerSprite.Play("stand"); // stand left
            spriteParent.localScale = new Vector3(1,1,1);
        }

        // falling
        if(character.grounded == false && currentAnim != anim.FallLeft && character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.FallLeft;
            playerSprite.Play("jump"); // fall left
            spriteParent.localScale = new Vector3(-1,1,1);
        }
        if(character.grounded == false && currentAnim != anim.FallRight && character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.FallRight;
            playerSprite.Play("jump"); // fall right
            spriteParent.localScale = new Vector3(1,1,1);
        }
    }
Example #19
0
 // Update is called once per frame
 void Update()
 {
     // Turn Left
     if(shark.isLeft && shark.idle && !shark.swim && currentAnim != anim.IdleLeft) {
         currentAnim = anim.IdleLeft;
         mySprite.Play("idleleft");
     }
     if(!shark.isLeft && shark.idle && !shark.swim && currentAnim != anim.IdleRight) {
         currentAnim = anim.IdleRight;
         mySprite.Play("idleright");
     }
     if(shark.isLeft && !shark.idle && shark.swim && currentAnim != anim.EatLeft) {
         currentAnim = anim.EatLeft;
         mySprite.Play("eatleft");
     }
     if(!shark.isLeft && !shark.idle && shark.swim && currentAnim != anim.EatRight) {
         currentAnim = anim.EatRight;
         mySprite.Play("eatright");
     }
 }
Example #20
0
    void Update()
    {
        if (mover)
        {
            if (passos > 100)
            {
                if (direcao)
                {
                    currentAnim = anim.ParouEsquerda;
                }
                else
                {
                    currentAnim = anim.ParouDireita;
                }


                direcao = !direcao;
                passos  = -20;
            }
            passos++;

            updateMovement();
        }
    }
Example #21
0
		void OnTriggerEnter(Collider otherObj)
		{
			Debug.Log("Colidiu!");
			Dialogos.exibirBoy = true;
			mover = false;	
			currentAnim = anim.andandoBaixo;
		}
Example #22
0
    public void Update()
    {
        anim lastAnim = battleAnimation;

        battleAnimation = anim.standing;

        if (hurt > 0)
        {
            hurt           -= 1;
            battleAnimation = anim.hurt;
        }
        if (defeated)
        {
            battleAnimation = anim.defeated;
        }
        if (performingAttack == 1 || performingAttack == 2)
        {
            switch (moveState)
            {
            case MoveState.approach:
                if (Vector2.Distance(transform.position, target.transform.position) > approachDistance)
                {
                    collisionBox.setHSpeed(moveSpeed);
                }
                else
                {
                    collisionBox.setHSpeed(0);
                    moveState       = MoveState.idle;
                    animationFrames = 0;
                }
                battleAnimation = anim.walking;
                break;

            case MoveState.idle:
                if (animationFrames == 4)
                {
                    combatManager.dealDamage();
                }
                if (animationFrames >= 16)
                {
                    moveState        = MoveState.retreat;
                    approachDistance = 0.5f;
                }
                battleAnimation = anim.attacking;
                break;

            case MoveState.retreat:
                if (Vector2.Distance(transform.position, origin) > approachDistance)
                {
                    collisionBox.setHSpeed(-moveSpeed);
                }
                else
                {
                    collisionBox.setHSpeed(0);
                    transform.position = origin;
                    moveState          = MoveState.idle;
                    performingAttack   = 0;
                    combatManager.endTurn();
                }
                battleAnimation = anim.walking;
                break;
            }
        }

        if (performingAttack == 3)
        {
            switch (moveState)
            {
            case MoveState.idle:
                if (animationFrames == 20)
                {
                    GameObject arrow = Instantiate(arrowObject, transform.position + new Vector3(0.1f, -0.15f), new Quaternion());
                    arrow.GetComponent <CombatProjectile>().target = target.transform.position;
                }
                if (animationFrames >= 50)
                {
                    performingAttack = 0;
                    combatManager.endTurn();
                }
                battleAnimation = anim.bow;
                break;
            }
        }

        if (performingAttack == 4)
        {
            switch (moveState)
            {
            case MoveState.approach:
                if (Vector2.Distance(transform.position, target.transform.position + Vector3.up * 7) > approachDistance)
                {
                    collisionBox.setSpeed(((target.transform.position + Vector3.up * 7) - transform.position).normalized * 0.8f);
                }
                else
                {
                    collisionBox.setSpeed(Vector2.zero);
                    moveState        = MoveState.idle;
                    approachDistance = 2;
                }
                battleAnimation = anim.jump;
                break;

            case MoveState.idle:
                if (Vector2.Distance(transform.position, target.transform.position) > approachDistance)
                {
                    collisionBox.setSpeed(((target.transform.position) - transform.position).normalized * 2);
                }
                else
                {
                    collisionBox.setSpeed(new Vector2(-moveSpeed * 0.3f, 0.5f));
                    moveState        = MoveState.retreat;
                    approachDistance = moveSpeed;
                    combatManager.dealDamage();
                }
                battleAnimation = anim.stomp;
                break;

            case MoveState.retreat:
                if (Vector2.Distance(transform.position, origin) > approachDistance)
                {
                    if (collisionBox.isGrounded())
                    {
                        collisionBox.setHSpeed(-moveSpeed);
                        collisionBox.setVSpeed(0);
                        battleAnimation = anim.walking;
                    }
                    else
                    {
                        collisionBox.setHSpeed(-moveSpeed * 0.3f);
                        collisionBox.setVSpeed(collisionBox.velocity.y - 0.03f);
                        battleAnimation = anim.jump;
                    }
                }
                else
                {
                    collisionBox.setHSpeed(0);
                    transform.position = origin;
                    moveState          = MoveState.idle;
                    performingAttack   = 0;
                    combatManager.endTurn();
                }

                break;
            }
        }

        animationFrames++;
        if (lastAnim != battleAnimation)
        {
            animationFrames = 0;
            foreach (string trigger in triggers)
            {
                animator.ResetTrigger(trigger);
            }
            animator.SetTrigger(triggers[(int)battleAnimation]);
        }

        collisionBox.movement();
    }
Example #23
0
    void Update()
    {
        animSprite.looping = true;
        // run left
        if(_character.isLeft && _character.grounded == true && currentAnim != anim.WalkLeft)
        {
            currentAnim = anim.WalkLeft;
            animSprite.Play("run");
            InvertSprite();
        }
        if(!_character.isLeft && _character.grounded == true && currentAnim != anim.StandLeft && _character.facingDir == Character.facing.Left && animPlaying == false)
        {
            currentAnim = anim.StandLeft;
            animSprite.Play("stand"); // stand left
            InvertSprite();
        }

        // run right
        if(_character.isRight && _character.grounded && currentAnim != anim.WalkRight)
        {
            currentAnim = anim.WalkRight;
            animSprite.Play("run");
            NormalScaleSprite();;
        }
        if(!_character.isRight && _character.grounded && currentAnim != anim.StandRight && _character.facingDir == Character.facing.Right && animPlaying == false)
        {
            currentAnim = anim.StandRight;
            animSprite.Play("stand"); // stand left
            NormalScaleSprite();
        }

        // falling
        if(_character.grounded == false && currentAnim != anim.FallLeft && _character.facingDir == Character.facing.Left)
        {
            currentAnim = anim.FallLeft;
            animSprite.Play("jump"); // fall left
            InvertSprite();
        }
        if(_character.grounded == false && currentAnim != anim.FallRight && _character.facingDir == Character.facing.Right)
        {
            currentAnim = anim.FallRight;
            animSprite.Play("jump"); // fall right
            NormalScaleSprite();
        }

        // PLAYER SPECIFIC ANIMS
        // Shooting
        if (_player.shootingKnife == true  && _character.facingDir == Character.facing.Left)
        {
            animPlaying = true;
            currentAnim = anim.ShootRight;
            animSprite.Play("throw_knife");
            InvertSprite();
            StartCoroutine( WaitAndCallback( animation.GetDuration(animation.framesets[3]) ) );
        }
        if (_player.shootingKnife == true && _character.facingDir == Character.facing.Right)
        {
            animPlaying = true;
            currentAnim = anim.ShootRight;
            animSprite.Play("throw_knife");
            NormalScaleSprite();
            StartCoroutine( WaitAndCallback( animation.GetDuration(animation.framesets[3]) ) );
        }

        //ENEMIES SPECIFIC ANIMS
        if (_character.isShot == true && _character.facingDir == Character.facing.Left)
        {
            animPlaying = true;
            animSprite.Play("hurt");
            StartCoroutine( WaitAndCallback( animation.GetDuration(animation.framesets[2]) ) );
            InvertSprite();
        }
        if (_character.isShot == true && _character.facingDir == Character.facing.Right)
        {
            animPlaying = true;
            animSprite.Play("hurt");
            StartCoroutine( WaitAndCallback( animation.GetDuration(animation.framesets[2]) ) );
            NormalScaleSprite();
        }

        if (_player.paused == true)
        {
            currentAnim = anim.None;
            animSprite.looping = false;
        }
        if (_character.isCrounch == true)
        {
            currentAnim = anim.Crounch;
            animSprite.Play("crounch");
        }
    }
Example #24
0
    void Update()
    {
        moverCamera = false;
        if (Input.GetKey(KeyCode.RightArrow))
        {
            movimentou = true;
            yAtual     = 0;
            xAtual     = 3;
            if (currentAnim != anim.andandoDireita)
            {
                currentAnim = anim.comecoAndarDireita;
            }
        }
        else if (Input.GetKey(KeyCode.LeftArrow))
        {
            movimentou = true;
            yAtual     = 0;
            xAtual     = -3;
            if (currentAnim != anim.andandoEsquerda)
            {
                currentAnim = anim.comecoAndarEsquerda;
            }
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
            movimentou = true;
            yAtual     = 3;
            xAtual     = -2;
            if (currentAnim != anim.andandoCima)
            {
                currentAnim = anim.comecoAndarCima;
            }
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            movimentou = true;
            yAtual     = -3;
            xAtual     = 2;
            if (currentAnim != anim.andandoBaixo)
            {
                currentAnim = anim.comecoAndarBaixo;
            }
        }

        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            currentAnim = anim.ParouEsquerda;
        }

        else if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            currentAnim = anim.ParouDireita;
        }

        else if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            currentAnim = anim.ParouCima;
        }

        else if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            currentAnim = anim.ParouBaixo;
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            xAtual *= 5;
            yAtual *= 5;
        }



        /*
         * if(currentAnim==1)
         * {
         * currentAnim = 3;
         * mySprite.ShowFrame(0);
         *
         * }else if(currentAnim==2)
         * {
         * currentAnim = 4;
         * mySprite.ShowFrame(9);
         *
         * }
         */

        /*
         *
         * if(Input.GetKey("a"))
         * {
         * movimentou = true;
         * yAtual = 0;
         * xAtual = -3;
         * mySprite.Play("left");
         * }
         * else if(Input.GetKey("d"))
         * {
         * movimentou = true;
         * yAtual = 0;
         * xAtual = 3;
         * }
         * else if(Input.GetKey("s"))
         * {
         * movimentou = true;
         * yAtual = -3;
         * xAtual = 0;
         * }
         *
         *
         */



        updateMovement();
    }
Example #25
0
 // Use this for initialization
 void Start()
 {
     Anima    = animAlfa;
     oStartUp = Time.realtimeSinceStartup;
 }
Example #26
0
    public void Update()
    {
        anim lastAnim = battleAnimation;

        battleAnimation = anim.standing;

        if (hurt > 0)
        {
            hurt           -= 1;
            battleAnimation = anim.hurt;
        }
        if (defeated)
        {
            battleAnimation = anim.defeated;
        }
        if (performingAttack == 1)
        {
            switch (moveState)
            {
            case MoveState.approach:
                if (Vector2.Distance(transform.position, target.transform.position) > approachDistance)
                {
                    collisionBox.setHSpeed(-moveSpeed);
                }
                else
                {
                    collisionBox.setHSpeed(0);
                    moveState       = MoveState.idle;
                    animationFrames = 0;
                }
                battleAnimation = anim.walking;
                break;

            case MoveState.idle:
                if (animationFrames == 20)
                {
                    combatManager.dealDamage();
                }
                if (animationFrames >= 33)
                {
                    moveState        = MoveState.retreat;
                    approachDistance = 0.5f;
                }
                battleAnimation = anim.attacking;
                break;

            case MoveState.retreat:
                if (Vector2.Distance(transform.position, origin) > approachDistance)
                {
                    collisionBox.setHSpeed(moveSpeed);
                }
                else
                {
                    collisionBox.setHSpeed(0);
                    transform.position = origin;
                    moveState          = MoveState.idle;
                    performingAttack   = 0;
                    combatManager.endTurn();
                }
                battleAnimation = anim.walking;
                break;
            }
        }

        animationFrames++;
        if (lastAnim != battleAnimation)
        {
            animationFrames = 0;
            foreach (string trigger in triggers)
            {
                animator.ResetTrigger(trigger);
            }
            animator.SetTrigger(triggers[(int)battleAnimation]);
        }

        collisionBox.movement();
    }
Example #27
0
    public void Update()
    {
        anim lastAnim = battleAnimation;

        battleAnimation = anim.standing;

        if (hurt > 0)
        {
            hurt           -= 1;
            battleAnimation = anim.hurt;
        }
        if (defeated)
        {
            battleAnimation = anim.defeated;
        }
        if (performingAttack == 1)
        {
            switch (moveState)
            {
            case MoveState.approach:
                battleAnimation = anim.attacking;
                if (animationFrames > 18)
                {
                    collisionBox.setSpeed((target.transform.position - transform.position).normalized * attackSpeed);
                }
                if (Vector2.Distance(transform.position, target.transform.position) < approachDistance)
                {
                    collisionBox.setSpeed(Vector2.zero);
                    moveState       = MoveState.retreat;
                    animationFrames = 0;
                    combatManager.dealDamage();
                }
                break;

            case MoveState.retreat:
                battleAnimation = anim.standing;
                collisionBox.setSpeed((origin - (Vector2)transform.position).normalized * flySpeed);
                if (Vector2.Distance(transform.position, origin) < approachDistance)
                {
                    collisionBox.setSpeed(Vector2.zero);
                    transform.position = origin;
                    moveState          = MoveState.idle;
                    performingAttack   = 0;
                    combatManager.endTurn();
                }
                break;
            }
        }

        animationFrames++;
        if (lastAnim != battleAnimation)
        {
            animationFrames = 0;
            foreach (string trigger in triggers)
            {
                animator.ResetTrigger(trigger);
            }
            animator.SetTrigger(triggers[(int)battleAnimation]);
        }

        collisionBox.movement();
    }
Example #28
0
		public void OnColissionEnter(Collision collision)
		{
		Debug.Log("Colidiu!");
			Dialogos.exibirOld = true;
			mover = false;	
			currentAnim = anim.andandoBaixo;
		}
Example #29
0
 // Use this for initialization
 void Start()
 {
     Anima    = animScaleUp;
     oStartUp = Time.realtimeSinceStartup;
 }
Example #30
0
	void Update () {
	
		
		moverCamera = false;
		if(Input.GetKey(KeyCode.RightArrow))
	    {       
			movimentou = true;
			yAtual = 0;
		    xAtual = 3;						
			if(currentAnim!= anim.andandoDireita)
	  		     currentAnim = anim.comecoAndarDireita;								
		}
		else if(Input.GetKey(KeyCode.LeftArrow))
	    {       
			movimentou = true;
			yAtual = 0;
		    xAtual = -3;						
			if(currentAnim!= anim.andandoEsquerda)
	  		     currentAnim = anim.comecoAndarEsquerda;							
		}		
		else if(Input.GetKey(KeyCode.UpArrow))
	    {       
			movimentou = true;
			yAtual = 3;
		    xAtual = -2;						
			if(currentAnim!= anim.andandoCima)
	  		     currentAnim = anim.comecoAndarCima;								
		}
		else if(Input.GetKey(KeyCode.DownArrow))
	    {       
			movimentou = true;
			yAtual = -3;
		    xAtual = 2;						
			if(currentAnim!= anim.andandoBaixo)
	  		     currentAnim = anim.comecoAndarBaixo;					
			
		}
		
		if(Input.GetKeyUp(KeyCode.RightArrow))
		{			
			currentAnim = anim.ParouEsquerda;
		}
		
		else if(Input.GetKeyUp(KeyCode.LeftArrow))
		{			
			currentAnim = anim.ParouDireita;
		}
		
		else if(Input.GetKeyUp(KeyCode.UpArrow))
		{			
			currentAnim = anim.ParouCima;
		}
		
		else if(Input.GetKeyUp(KeyCode.DownArrow))
		{			
			currentAnim = anim.ParouBaixo;
		}
						
		if(Input.GetKey(KeyCode.LeftShift))
		{
			xAtual *=5;
			yAtual *=5;
		}
		
		
		
		
		
		/*
		if(currentAnim==1)
		{		
	       currentAnim = 3;			
		   mySprite.ShowFrame(0);
	
		}else if(currentAnim==2)
		{		
	       currentAnim = 4;			
		   mySprite.ShowFrame(9);
	
		}
		*/			    
			
		/*
			
		if(Input.GetKey("a"))
		{   
		   movimentou = true;
		   yAtual = 0;
		   xAtual = -3;			
		   mySprite.Play("left");
		}
		else if(Input.GetKey("d"))
		{     	 
		   movimentou = true;
		   yAtual = 0;
		   xAtual = 3;
		}
		else if(Input.GetKey("s"))
		{     	 
		   movimentou = true;
		   yAtual = -3;
		   xAtual = 0;
		}
		
					
		*/	
												
		
				
		updateMovement();	
		
		
	}