Example #1
0
    private void OnMouseDown()
    {
        if (status.Equals("Active"))
        {
            Debug.Log("KlikitiKlik");
            waiting.SetActive(true);

            switch (currentCard.cardName)
            {
            case "Freeze":
            {
                FreezeScript scriptSettings = activated.transform.parent.gameObject.AddComponent <FreezeScript>();
                scriptSettings.time = currentCard.time;
                break;
            }

            case "Wall": {
                WallScript scriptSettings = activated.transform.parent.gameObject.AddComponent <WallScript>();
                scriptSettings.time = currentCard.time;
                break;
            }
            }

            activated.SetActive(false);
            status = "Waiting";
        }
    }
Example #2
0
    void Start()
    {
        if (transform.parent != null)
        {
            freeze = transform.parent.gameObject.GetComponent <FreezeScript>();
        }
        shootCooldown = 0f;


        if (AI_shoot == true)
        {
            portion = 360 / AI_n;
        }
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D otherCollider)
    {
        // Is this a shot?
        ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>();

        if (shot != null)
        {
            // Avoid friendly fire
            if (shot.isEnemyShot != isEnemy)
            {
                if (!reflect)
                {
                    Damage(shot.damage, shot.isSpreading);
                    if (shot.isFreezing)
                    {
                        freeze = GetComponent <FreezeScript> ();
                        if (freeze != null)
                        {
                            freeze.gotShot = true;
                        }
                    }
                    // Destroy the shot
                    Destroy(shot.gameObject);                      // Remember to always target the game object, otherwise you will just remove the script
                }
                else
                {
                    shotReflected    = true;
                    shot.isEnemyShot = !shot.isEnemyShot;
                    shot.damage      = 2 * shot.damage;
                    MoveScript     move   = otherCollider.gameObject.GetComponent <MoveScript>();
                    SpriteRenderer sprite = otherCollider.gameObject.GetComponent <SpriteRenderer> ();
                    sprite.color     = new Color(0.8f, 0.8f, 1, 1);
                    move.direction.x = -move.direction.x;
                    move.direction.y = -move.direction.y;
                }
            }
        }
        // Is it the Fire Shield?
        FireShieldScript shield = otherCollider.gameObject.GetComponent <FireShieldScript>();

        if ((shield != null) && (isEnemy))
        {
            Damage(3, false);
            shield.hit = true;
        }
    }