示例#1
0
    // Update is called once per frame
    void Update()
    {
        GameObject   boss2      = GameObject.Find("boss");
        bubbleShield bossScript = boss2.GetComponent <bubbleShield>();

        deleteInst = bossScript.delInst;

        timer += Time.fixedDeltaTime;

        if (timer > actionTimer && deleteInst == true)
        {
            Debug.Log("deleting inst");
            Destroy(gameObject);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        GameObject   boss2      = GameObject.Find("boss");
        bubbleShield bossScript = boss2.GetComponent <bubbleShield>();

        changeDir = bossScript.changeDirection;
        range     = bossScript.isInRange;

        changeDir = bossScript.changeDirection;
        //Debug.Log(changeDir);

        if (changeDir == true)
        {
            //Debug.Log("Deflect projectile");
            //playerProjectile.GetComponent<Rigidbody2D>().velocity = new Vector2(0, -movementSpeed * Time.fixedDeltaTime);

            //bossScript.changeDirection = false;

            // playerProjectile.velocity = (playerProjectile.velocity) * (-1);
        }
    }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        actionTimer += Time.fixedDeltaTime;

        GameObject   boss2      = GameObject.Find("boss");
        bubbleShield bossScript = boss2.GetComponent <bubbleShield>();

        changeDir = bossScript.changeDirection;
        range     = bossScript.isInRange;

        changeDir = bossScript.changeDirection;
        Debug.Log(changeDir);


        if (Input.GetKey("up"))
        {
            direction = 0F;
            spawnPos  = new Vector2(transform.position.x, transform.position.y + (playerSize.y * 2));
        }
        if (Input.GetKey("down"))
        {
            direction = 1F;
            spawnPos  = new Vector2(transform.position.x, transform.position.y - (playerSize.y * 2));
        }
        if (Input.GetKey("right"))
        {
            direction = 2F;
            spawnPos  = new Vector2(transform.position.x + (playerSize.x * 2), transform.position.y);
        }
        if (Input.GetKey("left"))
        {
            direction = 3F;
            spawnPos  = new Vector2(transform.position.x - (playerSize.x * 2), transform.position.y);
        }
        if (Input.GetKeyDown("x"))
        {
            if (actionTimer > 0.2)
            {
                //Activate animation for
                animator.SetTrigger("Shoot");
                //Debug.Log(spawnPos);
                GameObject projectileClone;
                projectileClone = Instantiate(playerProjectile, spawnPos, Quaternion.identity);
                //velocity.direction = direction;

                switch (direction)
                {
                case 0:
                    projectileClone.GetComponent <Rigidbody2D>().velocity = new Vector2(0, movementSpeed * Time.fixedDeltaTime);
                    break;

                case 1:
                    projectileClone.GetComponent <Rigidbody2D>().velocity = new Vector2(0, -movementSpeed * Time.fixedDeltaTime);
                    break;

                case 2:
                    projectileClone.GetComponent <Rigidbody2D>().velocity = new Vector2(movementSpeed * Time.fixedDeltaTime, 0);
                    break;

                case 3:
                    projectileClone.GetComponent <Rigidbody2D>().velocity = new Vector2(-movementSpeed * Time.fixedDeltaTime, 0);
                    break;
                }
                actionTimer = 0;
            }
        }
    }