Exemplo n.º 1
0
	public void SetBubbleType(string bubbletype){
		bubbleType = managerScript.man.bubbleDict[bubbletype];
		spr.sprite = bubbleType.sprites[4 - bubbleType.size];
		size = bubbleType.size;

		life = bubbleType.life;
		divisions = bubbleType.divideOnDeath;

		switch(bubbleType.size){
			case 4:
				col.size = new Vector2(1f, 1f);
			break;
			case 3:
				col.size = new Vector2(0.75f, 0.75f);
			break;
			case 2:
				col.size = new Vector2(0.5f, 0.5f);
			break;
			case 1:
				col.size = new Vector2(0.25f,0.25f);
			break;
		}
	}
Exemplo n.º 2
0
    public void controlChar()
    {
        if (Input.GetKey("d"))
        {
            if (!Input.GetKey("a"))
            {
                move(1, 0);
            }
        }
        if (Input.GetKey("a"))
        {
            if (!Input.GetKey("d"))
            {
                move(-1, 0);
            }
        }
        if (Input.GetKey("s"))
        {
            if (!Input.GetKey("w"))
            {
                move(0, 1);
            }
        }
        if (Input.GetKey("w"))
        {
            if (!Input.GetKey("s"))
            {
                move(0, -1);
            }
        }
        if (!Input.GetKey("w") && !Input.GetKey("s") && !Input.GetKey("a") && !Input.GetKey("d"))
        {
            if (bodyState.IsName("walk"))
            {
                anim.Play("idle");
            }
        }

        if (Input.GetKey("w") && Input.GetKey("s"))
        {
            speed.y = 0;
            if (bodyState.IsName("walk"))
            {
                anim.Play("idle");
            }
        }
        if (Input.GetKey("a") && Input.GetKey("d"))
        {
            speed.x = 0;
            if (bodyState.IsName("walk"))
            {
                anim.Play("idle");
            }
        }

        if (Input.GetMouseButton(1))
        {
            anim.Play("head_mouth_open");

            var em = absorbEffect.emission;
            em.enabled = true;
        }
        else
        {
            var em = absorbEffect.emission;
            em.enabled = false;

            if (Input.GetMouseButton(0))
            {
                anim.Play("head_mouth_open");

                if (cooldown == 0)
                {
                    managerScript.Bubble bubbleType = managerScript.man.bubbleDict[managerScript.man.currentBubble];
                    cooldown = bubbleType.cooldown;

                    float bulletAngle = headAngle + (bubbleType.number * 15f - 15f) / 2f;

                    for (int i = 0; i < bubbleType.number; i++)
                    {
                        Vector3 bubbleVector = new Vector3(Mathf.Cos(bulletAngle * Mathf.Deg2Rad), Mathf.Sin(bulletAngle * Mathf.Deg2Rad), 0f);

                        GameObject bubble;
                        bubble = Instantiate(bubblePrefab, axolotlHead.transform.position + bubbleVector * 1f, Quaternion.identity) as GameObject;

                        bubbleScript bscr = bubble.GetComponent <bubbleScript>();
                        bscr.SetBubbleType(managerScript.man.currentBubble);

                        float spread = Random.Range(-bubbleType.spread, bubbleType.spread);

                        bscr.speed = new Vector3(Mathf.Cos((bulletAngle + spread) * Mathf.Deg2Rad), Mathf.Sin((bulletAngle + spread) * Mathf.Deg2Rad), 0f) * bubbleType.speed;

                        bulletAngle -= 15f;
                    }
                }
            }
        }


        /*
         * if (Input.GetKeyDown("z")){
         *      attack();
         * }
         */

        if (!Input.GetKey("a") && !Input.GetKey("d"))
        {
            speed.x = 0;
        }

        if (!Input.GetKey("w") && !Input.GetKey("s"))
        {
            speed.y = 0;
        }
    }