// Update is called once per frame
 void Update()
 {
     if (test != Player.currState) {
         ChangePowerPicture();
         test = Player.currState;
     }
 }
예제 #2
0
 void ChangePowerPicture(KirbyStates state)
 {
     Texture newTexture = null;
     switch (state)
     {
         case KirbyStates.BEAM:
             newTexture = Resources.Load ("beam") as Texture;
             break;
         case KirbyStates.BYE:
             newTexture = Resources.Load ("bye") as Texture;
             break;
         case KirbyStates.CLEAR:
             newTexture = Resources.Load ("clear") as Texture;
             break;
         case KirbyStates.FIRE:
             newTexture = Resources.Load ("fire") as Texture;
             break;
         case KirbyStates.GOAL:
             newTexture = Resources.Load ("goal") as Texture;
             break;
         case KirbyStates.MISS:
             newTexture = Resources.Load ("miss") as Texture;
             break;
         case KirbyStates.NORMAL:
             newTexture = Resources.Load ("normal") as Texture;
             break;
         case KirbyStates.NOTHING:
             newTexture = Resources.Load ("nothing") as Texture;
             break;
         case KirbyStates.OUCH:
             newTexture = Resources.Load ("ouch") as Texture;
             break;
         case KirbyStates.SPARK:
             newTexture = Resources.Load ("spark") as Texture;
             break;
         default:
             newTexture = Resources.Load ("normal") as Texture;
             break;
     }
     powerPicture.texture = newTexture;
 }
 // Use this for initialization
 void Start()
 {
     ChangePowerPicture ();
     test = Player.currState;
 }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (GetComponent<Animator>().GetBool("jumping") && GetComponent<Animator>().GetInteger("jumpCount") > 0)
        {
            GetComponent<Animator>().Play("kirbyjump");
        }

        if (isSliding && localVel.velocity.x == 0.0f)
        {
            isSliding = false;
        }

        if (healthcount <= 0)
        {
            currState = KirbyStates.MISS;
            Death();
        }

        if (currState == KirbyStates.NOTHING && Time.time > delay + (2.0f * Time.deltaTime))
        {
            currState = KirbyStates.NORMAL;
        }

        if(!Grounded)
            GetComponent<Rigidbody2D>().gravityScale = 0.2f;

        if (!GetComponent<BoxCollider2D>().IsTouching(ground.GetComponent<EdgeCollider2D>()))
            Grounded = false;
    }
예제 #5
0
 //enum KirbyActions
 //{
 //    K_STAND,
 //    K_WALKLEFT,
 //    K_WALKRIGHT,
 //    K_DASH,
 //    K_JUMP,
 //    K_SUCK,
 //    K_BLOW,
 //    K_SPIT,
 //    K_CLIMB,
 //    K_COPY,
 //    K_ENTER_DOOR,
 //    K_ATTACK,
 //    K_CROUCH,
 //    K_SLIDE,
 //    K_FIRE,
 //    K_ICE,
 //    K_SPARK,
 //    K_BEAM,
 //    K_GET_HIT
 //}
 void Start()
 {
     GetComponent<SpriteRenderer>().enabled = false;
     localVel = GetComponent<Rigidbody2D>();
     Avatar = GetComponent<SpriteRenderer>().sprite;
     reversed = false;
     isDashing = false;
     //anim = GetComponent<Animator>();
     // message = KirbyActions.K_IDLE;
     currState = KirbyStates.NORMAL;
     SuckZone.GetComponent<ParticleSystem>().Stop();
     soundPlayer = GetComponent<AudioSource>();
     GetComponent<SpriteRenderer>().enabled = true;
 }
예제 #6
0
    void FixedUpdate()
    {
        doubletap = false;

        //float move = Input.GetAxis("Horizontal");

        //anim.SetFloat("move", Mathf.Abs(move));

        //WASD controls
        if (Input.GetKeyDown(KeyCode.W))
        {
            //message = KirbyActions.K_JUMP;
            //Jump
            if (jumpcount == 0 && Grounded)
            {
                GetComponent<Rigidbody2D>().AddForce(new Vector2(0.0f, 275.0f));
                //transform.Translate(new Vector3(0.0f, 0.5f, 0.0f));
                Grounded = false;
                //GetComponent<Animator>().SetBool("jumping", true);
                jumpcount++;
                //Avatar = Airpuff1;
                lastjump = Time.time;

            }
            else if (jumpcount <= 5 && !Grounded && Time.time > lastjump + delay)
            {
                GetComponent<Rigidbody2D>().AddForce(new Vector2(0.0f, 255.0f));
                //transform.Translate(new Vector3(0.0f, 0.4f, 0.0f));
                jumpcount++;
                GetComponent<Animator>().SetInteger("jumpCount", jumpcount);
                if (jumpcount == 5)
                {
                    //Animation sprite that puffs;
                    //Avatar = Airpuff1;
                    //Invoke("JumpDelay", 0.0f);
                }
                GetComponent<Animator>().SetBool("jumping", true);
            }
            else
            {
                //Lets out air and falls
            }

            if (GetComponent<BoxCollider2D>().IsTouching(GameObject.Find("Door").GetComponent<BoxCollider2D>()))
            {
                LeaveArea();
            }

        }

        if (Input.GetKey(KeyCode.A) && !IsCrouched && !GetComponent<Animator>().GetBool("isSucking"))
        {

            //if (Time.time < _taptime + 0.4f)
            //    doubletap = true;
            //else
            //    _taptime = Time.time;

            //if (doubletap)
            //{
            //    if (!reversed)
            //    {
            //        transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
            //        reversed = true;
            //    }
            //    transform.Translate(new Vector3(-2.0f * Time.deltaTime, 0.0f, 0.0f));
            //    //dashleft();
            //}
            //else
            //{
            //    if (!reversed)
            //    {
            //        transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
            //        reversed = true;
            //    }
            //   //while (Input.GetKey(KeyCode.A))
            //        transform.Translate(new Vector3(-1.0f * Time.deltaTime, 0.0f, 0.0f));
            //}
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(-2.0f * Time.deltaTime, 0.0f, 0.0f));
                if (!reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = true;
                }
            }
            else
            {
                //Avatar = walking
                transform.Translate(new Vector3(-1.0f * Time.deltaTime, 0.0f, 0.0f));
                if (!reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = true;
                }
            }

            GetComponent<Animator>().SetBool("move", true);

            if (GetComponent<BoxCollider2D>().IsTouching(GameObject.Find("Ground").GetComponent<BoxCollider2D>()))
                GetComponent<Animator>().Play("WalkingCycle");
            GetComponent<Animator>().SetBool("move", true);

            if (GetComponent<BoxCollider2D>().IsTouching(GameObject.Find("Ground").GetComponent<BoxCollider2D>()))
                GetComponent<Animator>().Play("WalkingCycle");
            GetComponent<Animator>().SetBool("move", true);

            if(GetComponent<BoxCollider2D>().IsTouching(GameObject.Find("Ground").GetComponent<BoxCollider2D>()))

            GetComponent<Animator>().SetBool("move", true);
            if (GetComponent<Rigidbody2D>().gravityScale != 0.2f)
                GetComponent<Rigidbody2D>().gravityScale = 0.2f;

            if (Grounded)
                GetComponent<Animator>().Play("WalkingCycle");
            //GetComponent<Animator>().SetBool("move", true);
            //if(Grounded)
            //    GetComponent<Animator>().Play("WalkingCycle");

        }
        else if (Input.GetKey(KeyCode.S))
        {
            //GetComponent<SpriteRenderer>().sprite = crouching;
            IsCrouched = true;

        }
        else if (Input.GetKey(KeyCode.D) && !IsCrouched && !GetComponent<Animator>().GetBool("isSucking"))
        {
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(2.0f * Time.deltaTime, 0.0f, 0.0f));
                if (reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = false;
                }
            }
            else
            {
                //Avatar = walking
                transform.Translate(new Vector3(1.0f * Time.deltaTime, 0.0f, 0.0f));
                if (reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = false;
                }
            }
            GetComponent<Animator>().SetBool("move", true);

            if (GetComponent<BoxCollider2D>().IsTouching(GameObject.Find("Ground").GetComponent<BoxCollider2D>()))
                GetComponent<Animator>().Play("WalkingCycle");

            if (GetComponent<Rigidbody2D>().gravityScale != 0.2f)
                GetComponent<Rigidbody2D>().gravityScale = 0.2f;
            if (Grounded)
                GetComponent<Animator>().Play("WalkingCycle");

        }
        else
        {
            GetComponent<Animator>().SetBool("move", false);
            //GetComponent<Animator>().SetBool("jumping", false);
            //message = KirbyActions.K_IDLE;
            if (Grounded == true && !GetComponent<Animator>().GetBool("isSucking"))
            { GetComponent<Animator>().Play("Idle");
             GetComponent<Rigidbody2D>().gravityScale = 1.0f;}
            IsCrouched = false;
            if (SuckZone.GetComponent<BoxCollider2D>().enabled)
            {
                SuckZone.GetComponent<BoxCollider2D>().enabled = false;
                GetComponent<Animator>().SetBool("isSucking", false);
              //  if (particles.isPlaying)
                   // particles.Stop();

            }
            transform.position = transform.position;

        }

        //Action buttons
        if (Input.GetKey(KeyCode.Space))
        {
            //Sucking Code
            if (!SuckZone.GetComponent<BoxCollider2D>().enabled)
            {
                SuckZone.GetComponent<BoxCollider2D>().enabled = true;
                GetComponent<Animator>().SetBool("isSucking", true);
                if (!particles.IsAlive(false) && !particles.isPlaying)
                {
                    Debug.Log("Particles not living. Creating Particles");
                    particles.enableEmission = true;
                    particles.Play();
                }
                //GetComponent<Animator>().Play("kirbySuck");
            }

            if (SuckZone.GetComponent<ParticleSystem>().isPlaying)
            {
                //if (!particles.IsAlive(false))
                if (particles.particleCount < 10)
                    Debug.Log("Particles Low");
                else
                    Debug.Log("Particles above average");
            }
            //If something in mouth
            if (MouthFull)
            {

            }
            //If player has an ability
            if (currState > KirbyStates.NORMAL)
            {
                //KirbyPowers.SendMessage("KirbyAbility", currState);
            }

            if (IsCrouched && Input.GetKey(KeyCode.D) && !isSliding)
            {
                isSliding = true;
                localVel.AddForce(new Vector2(200.0f, 0.0f));
                //transform.Translate(new Vector3(2.0f, 0.0f, 0.0f));
                //GetComponent<Animator>().SetBool("StringSlide", true);
                if (reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = false;
                }
            }
            else if (IsCrouched && Input.GetKey(KeyCode.A) && !isSliding)
            {
                isSliding = true;
                localVel.AddForce(new Vector2(-200.0f, 0.0f));
                //transform.Translate(new Vector3(-2.0f, 0.0f, 0.0f));
                //GetComponent<Animator>().SetBool("StringSlide", true);
                if (!reversed)
                {
                    transform.localScale = new Vector3(transform.localScale.x * -1.0f, transform.localScale.y, transform.localScale.z);
                    reversed = true;
                }
            }

            ////Sucking Code
           // if(!SuckZone.enabled)
          //  SuckZone.enabled = true;
            //If something in mouth
            //if (MouthFull)

            //If player has an ability

        }

        //Extra Button
        if (Input.GetKey(KeyCode.RightShift))
        {
            //Release Ability
            currState = KirbyStates.NORMAL;

        }

        //SendMessage("DoStuff", message);
    }
예제 #7
0
 void EnemySuckedIn(GameObject enemy, int state)
 {
     MouthFull = true;
     GetComponent<Animator>().SetBool("isSucking", false);
     SuckZone.SetActive(false);
     if (state > 5)
     {
         currState = (KirbyStates)state;
     }
     else
         currState = KirbyStates.NOTHING;
     enemy.SetActive(false);
     delay = Time.time;
 }