예제 #1
0
	private void UpdateAnimation(bool moving, WalkDirection direction) {
		OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>();

		if(isCurrentlySwinging) {
			return;
		}
				
		if(moving && currentWalkDirection != direction) {
			if(direction == WalkDirection.LEFT) {
				sprite.PlayLoop("walkLeft");
			} else {
				sprite.PlayLoop("walkRight");
			}
		}
		
		if(moving) {
			if(!sprite.isPlaying) {
				sprite.Play();
			}
		} else {
			sprite.Pauze();
			sprite.frameIndex = 1;
			if (direction == WalkDirection.LEFT) {
				sprite.frameIndex += 4;
			}
		}
		
		if(falling) {
			sprite.Pauze();
			sprite.frameIndex = 0;
			if (direction == WalkDirection.LEFT) {
				sprite.frameIndex += 4;
			}
		}
	}
예제 #2
0
    // Use this for initialization
    void Start()
    {
        anim = this.gameObject.GetComponent <OTAnimatingSprite>();
        anim.Play();

        //DontDestroyOnLoad(this.gameObject);
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (BonecoChange.currentAnim == BonecoChange.anim.comecoAndarDireita)
        {
            mySprite.Play("right");
            BonecoChange.currentAnim = BonecoChange.anim.andandoDireita;
        }

        else if (BonecoChange.currentAnim == BonecoChange.anim.comecoAndarEsquerda)
        {
            mySprite.Play("left");
            BonecoChange.currentAnim = BonecoChange.anim.andandoEsquerda;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.comecoAndarCima)
        {
            mySprite.Play("up");
            BonecoChange.currentAnim = BonecoChange.anim.andandoCima;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.comecoAndarBaixo)
        {
            mySprite.Play("down");
            BonecoChange.currentAnim = BonecoChange.anim.andandoBaixo;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.ParouDireita)
        {
            mySprite.ShowFrame(9);
            BonecoChange.currentAnim = BonecoChange.anim.parado;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.ParouEsquerda)
        {
            mySprite.ShowFrame(0);
            BonecoChange.currentAnim = BonecoChange.anim.parado;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.ParouCima)
        {
            mySprite.ShowFrame(18);
            BonecoChange.currentAnim = BonecoChange.anim.parado;
        }
        else if (BonecoChange.currentAnim == BonecoChange.anim.ParouBaixo)
        {
            mySprite.ShowFrame(27);
            BonecoChange.currentAnim = BonecoChange.anim.parado;
        }
    }
예제 #4
0
    void Start()
    {
        mySprite = GetComponent<OTAnimatingSprite>();
        // Start the player in the left facing position.
        mySprite.Play ("runLeft");

        // These determine which direction the player is moving and if they are in motion.
        climbing = false;
        moveLeft = false;
        moveRight = false;
    }
예제 #5
0
 void Awake()
 {
     //manager = UnitManager.getInstance();
     if(animated) {
         animatingProjectileSprite = GetComponent<OTAnimatingSprite>();
         animatingProjectileSprite.onCollision = OnCollision;
         animatingProjectileSprite.Play(72);
     }else {
         projectileSprite = GetComponent<OTSprite>();
         projectileSprite.onCollision = OnCollision;
     }
 }
예제 #6
0
    private IEnumerator playResultAnimation(OTAnimatingSprite anim, string soundName)
    {
        //Debug.Log ("Started Playing");
        anim.GetComponent<Renderer>().enabled = true;
        anim._numberOfPlays = 1;
        anim.Play();
        OTSound sound = new OTSound(soundName);
        sound.Play();
        //Debug.Log("Funcion delay");
        yield return new WaitForSeconds(1f);

        //Debug.Log ("finished Playing");
        anim.GetComponent<Renderer>().enabled = false;
    }
예제 #7
0
    // Update is called once per frame
    void Update()
    {
        if (player_control.speed.x < 0 &&
            animation_status != AnimationStatus.RunLeft)
        {
            sprite_parent.localScale = new Vector3(1, 1, 1);
            player_sprite.Play("Run");
            animation_status = AnimationStatus.RunLeft;
        }
        else if (player_control.speed.x > 0 &&
                 animation_status != AnimationStatus.RunRight)
        {
            sprite_parent.localScale = new Vector3(-1, 1, 1);
            player_sprite.Play("Run");
            animation_status = AnimationStatus.RunRight;
        }
        else
        {
            player_sprite.Play("Stand");
            if (sprite_parent.localScale.x < 0)
            {
                animation_status = AnimationStatus.StandRight;
            }
            else
            {
                animation_status = AnimationStatus.StandLeft;
            }
        }

        if (player_control.speed.y != 0 &&
            animation_status != AnimationStatus.Jump)
        {
            animation_status = AnimationStatus.Jump;
            player_sprite.Play("Jump");
        }
    }
예제 #8
0
    /* ============================== SHOOT ====================================================================== */

    IEnumerator Shoot()
    {
        xa.shooting = true;

        // show the shoot sprite and play the animation
        shootRenderer.enabled = true;
        shootSprite.Play("shoot");

        // check facing direction and flip the shoot parent to the correct side
        if (xa.facingDir == 1)
        {
            shootParent.localScale = new Vector3(1, 1, 1);           // left side
        }
        if (xa.facingDir == 2)
        {
            shootParent.localScale = new Vector3(-1, 1, 1);           // right side
        }

        yield return(new WaitForSeconds(0.4f));

        // hide the sprite
        shootRenderer.enabled = false;
        xa.shooting           = false;
    }
예제 #9
0
 void Start()
 {
     Sprite.Play("Walk");
     currentHP = InitialHP;
     dying     = false;
 }
예제 #10
0
    private void Update()
    {
        if (state == HeartStates.Dead)
        {
            return;
        }

        if (state == HeartStates.Dying)
        {
            Sprite.looping = false;
            Sprite.Play(state.ToString());
            Sprite.onAnimationFinish = delegate
            {
                GameState.CurrentState = LevelState.PlayerWon;
            };
            state = HeartStates.Dead;
        }
        else
        {
            elapsedTimeForBeat += Time.deltaTime;
            if (elapsedTimeForBeat > heartBeatInterval)
            {
                elapsedTimeForBeat = 0;
                Sprite.Play(state.ToString());
                GameState.Audio.playHearthBeat1();
            }

            if (GameState.CurrentState == LevelState.WaveStarted)
            {
                elapsedTimeForAttack += Time.deltaTime;
                if (elapsedTimeForAttack > AttackInterval)
                {
                    Debug.Log(string.Format("HeartBehavior: Decrementando HP -{0} (AUTO)", HealthDecrement));
                    elapsedTimeForAttack = 0;
                    currentHP           -= HealthDecrement;

                    if (currentHP > MaxHealth)
                    {
                        GameState.CurrentState = LevelState.HeartWon;
                    }
                    else if (currentHP > HealthBar)
                    {
                        state             = HeartStates.Health;
                        heartBeatInterval = HealthBeatInterval;
                    }
                    else if (currentHP > SickBar)
                    {
                        state             = HeartStates.Sick;
                        heartBeatInterval = SickBeatInterval;
                    }
                    else if (currentHP > MoreSickBar)
                    {
                        state             = HeartStates.MoreSick;
                        heartBeatInterval = MoreSickBeatInterval;
                    }
                    else if (currentHP > 0)
                    {
                        heartBeatInterval = CriticBeatInterval;
                        Sprite.speed      = 1.5f;
                    }
                    else
                    {
                        state              = HeartStates.Dying;
                        heartBeatInterval  = 0;
                        elapsedTimeForBeat = 0;
                        Sprite.speed       = 1;
                    }
                }
            }
        }
    }
예제 #11
0
    void Update()
    {
        // run left
        if (xa.isLeft && !xa.onRope && !xa.onLadder && !xa.falling && currentAnim != xa.anim.WalkLeft)
        {
            currentAnim = xa.anim.WalkLeft;
            mySprite.Play("runLeft");
        }
        if (!xa.isLeft && !xa.onRope && !xa.falling && currentAnim != xa.anim.StandLeft && xa.facingDir == 1)
        {
            currentAnim = xa.anim.StandLeft;
            mySprite.Play("standLeft");             // stand left
        }

        // run right
        if (xa.isRight && !xa.onRope && !xa.onLadder && !xa.falling && currentAnim != xa.anim.WalkRight)
        {
            currentAnim = xa.anim.WalkRight;
            mySprite.Play("runRight");
        }
        if (!xa.isRight && !xa.onRope && !xa.falling && currentAnim != xa.anim.StandRight && xa.facingDir == 2)
        {
            currentAnim = xa.anim.StandRight;
            mySprite.Play("standRight");             // stand left
        }

        // climb
        if (xa.isUp && xa.onLadder && currentAnim != xa.anim.Climb)
        {
            currentAnim = xa.anim.Climb;
            mySprite.Play("climb");
        }
        if (!xa.isUp && xa.onLadder && currentAnim != xa.anim.ClimbStop && xa.facingDir == 3)
        {
            currentAnim = xa.anim.ClimbStop;
            mySprite.ShowFrame(1);             // climb left
        }

        if (xa.isDown && xa.onLadder && currentAnim != xa.anim.Climb)
        {
            currentAnim = xa.anim.Climb;
            mySprite.Play("climb");
        }
        if (!xa.isDown && xa.onLadder && currentAnim != xa.anim.ClimbStop && xa.facingDir == 4)
        {
            currentAnim = xa.anim.ClimbStop;
            mySprite.ShowFrame(1);             // climb left
        }

        // rope
        if (xa.isLeft && xa.onRope && currentAnim != xa.anim.RopeLeft)
        {
            currentAnim = xa.anim.RopeLeft;
            mySprite.Play("ropeLeft");
        }
        if (!xa.isLeft && xa.onRope && currentAnim != xa.anim.HangLeft && xa.facingDir == 1)
        {
            currentAnim = xa.anim.HangLeft;
            mySprite.ShowFrame(6);             // hang left
        }

        if (xa.isRight && xa.onRope && currentAnim != xa.anim.RopeRight)
        {
            currentAnim = xa.anim.RopeRight;
            mySprite.Play("ropeRight");
        }
        if (!xa.isRight && xa.onRope && currentAnim != xa.anim.HangRight && xa.facingDir == 2)
        {
            currentAnim = xa.anim.HangRight;
            mySprite.ShowFrame(9);             // hang right
        }

        // falling
        if (xa.falling && currentAnim != xa.anim.FallLeft && xa.facingDir == 1)
        {
            currentAnim = xa.anim.FallLeft;
            mySprite.ShowFrame(2);             // fall left
        }
        if (xa.falling && currentAnim != xa.anim.FallRight && xa.facingDir == 2)
        {
            currentAnim = xa.anim.FallRight;
            mySprite.ShowFrame(3);             // fall right
        }

        // shooting
        if (xa.shooting && currentAnim != xa.anim.ShootLeft && xa.facingDir == 1)
        {
            currentAnim = xa.anim.ShootLeft;
            mySprite.ShowFrame(10);             // shoot left
        }
        if (xa.shooting && currentAnim != xa.anim.ShootRight && xa.facingDir == 2)
        {
            currentAnim = xa.anim.ShootRight;
            mySprite.ShowFrame(11);             // shoot right
        }
    }
예제 #12
0
    /// <summary> 
    /// Assign proper container to animation sprite object
    /// </summary>
    /// <param name="_aniSp"> name of animation container. </param>
    /// <param name="_frameIndex"> frame index of symbol in static icons sprite sheet. </param>
    /// <param name="_i"> index of animation sprites </param>
    private void UpdateAniContainer(ref OTAnimatingSprite _aniSp, int _frameIndex, bool _isPlay, int _i)
    {
        string acName = (_frameIndex < 10)? "Icon0" + _frameIndex + "_ani_00_Altas" :  "Icon" + _frameIndex + "_ani_00_Altas";
        string aniName = (_frameIndex < 10)? "Icon0" + _frameIndex + "_Ani" :  "Icon" + _frameIndex + "_Ani";

        _aniSp.spriteContainer = GameObject.Find(acName).GetComponent<OTSpriteAtlasCocos2D>();
        _aniSp.animation = GameObject.Find(aniName).GetComponent<OTAnimation>();

        if(_isPlay)
        {
            _aniSp.Play();
            //	_aniSp.looping = true;
            m_AniSpr[_i].playOnStart = true;
            _aniSp.alpha = 1f;
            _aniSp.frameIndex = 0;
            foreach (OTAnimatingSprite os in m_AniSpr)
                os.frameIndex = 0;
        }

        _aniSp.numberOfPlays = 1;

        if(_frameIndex < GameVariables.Instance.SCATTER_INDEX)
        {
            _aniSp.size = new Vector2 (180, 180);
            if(_frameIndex == 11) //! bell index
                _aniSp.size = new Vector2 (170, 170);
        }
        else // substitute and sactter animation icons
        {
            if(_frameIndex == GameVariables.Instance.SCATTER_INDEX)
            {
                _aniSp.size = new Vector2 (300, 300);
                _aniSp.numberOfPlays = 2;
            }
            else //subs
            {
                _aniSp.size =  new Vector2 (250, 250);
                _aniSp.alpha = 0.999f;
            }

        }

        if (_frameIndex != GameVariables.Instance.SCATTER_INDEX)  // excecpt scatter.
            _aniSp.onAnimationFinish = AnimationFinsh;
        else
            _aniSp.onAnimationFinish = null;
    }
예제 #13
0
    // Use this for initialization
    public void Setup(LevelManager _lev)
    {
        coneParent = FETool.findWithinChildren(gameObject, "ParentCone");
        gameSprite = FETool.findWithinChildren(gameObject, "Sprite");
        bubble = FETool.findWithinChildren(gameObject, "Bubble").GetComponentInChildren<OTSprite>();
        levMan = _lev;
        initpos = transform.position;

        RayDL = FETool.findWithinChildren(gameObject, "RayOrigin_DL").transform;
        RayUL = FETool.findWithinChildren(gameObject, "RayOrigin_DR").transform;
        RayDR = FETool.findWithinChildren(gameObject, "RayOrigin_UL").transform;
        RayUR = FETool.findWithinChildren(gameObject, "RayOrigin_UR").transform;

        paper = FETool.findWithinChildren(gameObject, "Paper").GetComponentInChildren<OTSprite>();
        papertxt = FETool.findWithinChildren(gameObject, "Paper").GetComponentInChildren<TextUI>();
        papertxt.color = Color.clear;

        spr = GetComponentInChildren<OTAnimatingSprite>();
        spr.Play("static");

        coneCollider = coneParent.GetComponentInChildren<BoxCollider>();
        coneRenderer = coneParent.GetComponentInChildren<LineRenderer>();
        halfMyY = 0.25f;

        bubble.alpha = 0f;

        GameEventManager.GameOver += GameOver;
        GameEventManager.Respawn += Respawn;
        GameEventManager.GameStart += GameStart;
        GameEventManager.EndGame += EndGame;
    }
예제 #14
0
	// Update is called once per frame
	void Update () {
		Vector3 moveRequest = new Vector3();
		
		moveRequest = new Vector3(Input.GetAxisRaw("Horizontal"), 0.0f, 0.0f);
		WalkDirection direction = currentWalkDirection;

		if (moveRequest.sqrMagnitude > 0.0) {
			moveRequest.Normalize();
			
			if (moveRequest.x > 0) {
				direction = WalkDirection.RIGHT;
			} else {
				direction = WalkDirection.LEFT;
			}	
		}
		
		if(Input.GetKeyDown(KeyCode.Z) && !isCurrentlySwinging) {
			isCurrentlySwinging = true;
			
			OTAnimatingSprite sprite = GetComponent<OTAnimatingSprite>();
			if(direction == WalkDirection.LEFT) {
				sprite.PlayOnce("catchLeft");
			} else {
				sprite.PlayOnce("catchRight");
			}
			sprite.Play();
			sprite.onAnimationFinish = OnSwingDone;
		}
		
		if(isCurrentlySwinging) {
			float netXCoord;
			if(direction == WalkDirection.LEFT) {
				netXCoord = -64.0f;
			} else {
				netXCoord = 24.0f;
			}
				
			Rect net = new Rect(this.transform.position.x + netXCoord, this.transform.position.y - 30f, 40f, 60f);
			
			bool captured = fireflies.Captures(net);
			if(captured) {
				Debug.Log ("Got one!");
				pickupSound.Play();
				
				OTAnimatingSprite firefly = (OTAnimatingSprite) OT.CreateSprite("Firefly");
				firefly.GetComponent<Firefly>().enabled = false;
				firefly.depth = -100;
				firefly.size = new Vector2(64f, 64f);
				firefly.pivot = OTObject.Pivot.BottomLeft;
				firefly.PlayLoop("right");
				
				uiFireflies.Add (firefly);
				
				OnSwingDone(null);
			}
		}
		
		moveRequest *= Time.deltaTime * moveSpeed;
		
		bool wasFalling = falling;
		falling = terrain.CanMoveTo(this.transform.localPosition.x, this.transform.localPosition.y - 1.2f, collidingBox);
		
		if(!falling && !terrain.CanMoveTo(this.transform.localPosition.x + moveRequest.x * 10f, this.transform.localPosition.y - 1.2f, collidingBox)) {
			lastJumpPos = this.transform.localPosition;
			lastJumpCount = uiFireflies.Count;
		}
		

		moveRequest = terrain.Move(this.transform.localPosition, collidingBox, moveRequest);
		this.transform.Translate(moveRequest);
		
		
		if(wasFalling && !falling) {
			landSound.Play();
		}
		
		if(!falling && verticalSpeed < 0f) {
			verticalSpeed = 0f;
			
			if(Input.GetKeyDown(KeyCode.Space)) {
				jumpSound.Play();
				verticalSpeed = jumpSpeed;
			}
		}
		
		Fall();
		UpdateAnimation(moveRequest.sqrMagnitude > 0.0, direction);
		
		currentWalkDirection = direction;
		
		UpdateDialog();
		
		UpdateEvents();
		
		UpdateUISprites();
		
		if(this.transform.localPosition.y < 100) {
			this.transform.localPosition = lastJumpPos;
			while(uiFireflies.Count > lastJumpCount) {
				uiFireflies.RemoveAt(0);
			}
		}

	}