protected virtual void Update()
 {
     if (!Globals.canvas.dialogue)
     {
         frame++;
         spinning.RemoveAll((GameObject target) => target == null);
         foreach (GameObject spun in spinning)
         {
             Quaternion rotation = spun.transform.rotation;
             spun.transform.RotateAround(this.transform.position, Vector3.forward, rotationSpeed);
             spun.transform.rotation = rotation;
             if (frame >= framesBetweenDamage)
             {
                 KillableGridObject killable = spun.GetComponent <KillableGridObject>();
                 if (killable)
                 {
                     killable.TakeDamage(damage);
                 }
             }
         }
         if (frame >= framesBetweenDamage)
         {
             frame = 0;
         }
     }
 }
    //deal damage; only works when colliders are enabled
    public void OnTriggerEnter2D(Collider2D other)
    {
        KillableGridObject killable = other.GetComponent <KillableGridObject>();

        if (killable)
        {
            killable.TakeDamage(damage);
        }
    }
 void OnTriggerEnter2D(Collider2D other)
 {
     if ((!other.isTrigger || other.CompareTag("Ground")) && !other.gameObject.CompareTag("Enemy") && !other.CompareTag("Lava") && !other.CompareTag("Player") && other.isActiveAndEnabled)
     {
         nonLavaObjects++;
     }
     if (other.gameObject.CompareTag("Enemy") || other.gameObject.CompareTag("EnemySpawner"))
     {
         KillableGridObject enemy = other.GetComponentInParent <KillableGridObject>();
         //killList.Add(enemy);
         enemy.TakeDamage(GetComponentInParent <PlatformGridObject>().damage);
     }
 }
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.CompareTag("Player"))
        {
            moveList.Add(col.gameObject);
            PlayerGridObject player = col.GetComponent <PlayerGridObject>();
            player.platforms++;
            hasPlayer = true;
        }
        if (col.gameObject.CompareTag("Enemy") || col.gameObject.CompareTag("EnemySpawner"))
        {
            //there's a bug where the platform is stuck in the middle of lava if it hits a firemonster

            /*if (col.gameObject.GetComponent<GenericMonsterBehaviour>())
             * {
             *  return;
             * }*/
            KillableGridObject enemy = col.GetComponentInParent <KillableGridObject>();
            enemy.TakeDamage(damage);
        }
        if (!pingPong && col.gameObject.CompareTag("Turbine") && !col.gameObject.GetComponent <TurbinePlantObject>().onPlatform)
        {
            col.gameObject.GetComponent <TurbinePlantObject>().onPlatform = true; //makes sure turbine can only be on one platform
            if (!turbineMove)
            {
                if (col.gameObject.GetComponentInParent <TurbinePlantObject>().direction == Globals.Direction.West)
                {
                    direction = Globals.Direction.East;
                }
                else if (col.gameObject.GetComponentInParent <TurbinePlantObject>().direction == Globals.Direction.East)
                {
                    direction = Globals.Direction.West;
                }
                else if (col.gameObject.GetComponentInParent <TurbinePlantObject>().direction == Globals.Direction.North)
                {
                    direction = Globals.Direction.South;
                }
                else if (col.gameObject.GetComponentInParent <TurbinePlantObject>().direction == Globals.Direction.South)
                {
                    direction = Globals.Direction.North;
                }
            }
            plant = col.gameObject.GetComponent <PlantGridObject>();

            moveList.Add(col.gameObject);
            hasTurbine  = true;
            turbineMove = true;
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if ( ((other.gameObject.tag == "Enemy" || other.gameObject.tag == "EnemySpawner") && !evil) || (evil && other.gameObject.tag == "Player"))
        {
            KillableGridObject killable = other.GetComponent<KillableGridObject>();
            if (evil)
            {
                other.GetComponent<PlayerGridObject>().TakeDamage(damage);
            }

            if (!killable.isInvulnerable && !evil)
            {
                Destroy(this.gameObject);
                enemy = other.gameObject.GetComponent<KillableGridObject>();
                enemy.TakeDamage(damage);
            }
        }
    }
Esempio n. 6
0
 void OnCollisionEnter2D(Collision2D coll) {
     KillableGridObject killable = coll.gameObject.GetComponent<KillableGridObject>();
     if (killable)
         killable.TakeDamage(damage);
 }