コード例 #1
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.CompareTag("Enemy") || other.CompareTag("EnemySpawner"))
     {
         triggered = null;
     }
 }
コード例 #2
0
 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;
         }
     }
 }
コード例 #3
0
    //deal damage; only works when colliders are enabled
    public void OnTriggerEnter2D(Collider2D other)
    {
        KillableGridObject killable = other.GetComponent <KillableGridObject>();

        if (killable)
        {
            killable.TakeDamage(damage);
        }
    }
コード例 #4
0
 public override void Start()
 {
     killable = GetComponent <KillableGridObject>();
     if (level <= 0)
     {
         killable.isInvulnerable = true;
     }
     base.Start();
 }
コード例 #5
0
    /// <summary>
    /// Create the status effect game object to apply onto the target
    /// </summary>
    public static void ApplyStatusEffect(KillableGridObject caster, KillableGridObject target, GameObject statusEffectPrefab)
    {
        // Create status effect object instance to get the status effect component
        GameObject   statusEffectObject = (GameObject)Instantiate(statusEffectPrefab);
        StatusEffect statusEffect       = statusEffectObject.GetComponent <StatusEffect>();

        statusEffect.effectCaster   = caster;
        statusEffect.affectedTarget = target;

        statusEffect.ApplyEffect();
    }
コード例 #6
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (!other.isTrigger || other.GetComponent <PlantGridObject>() || other.CompareTag("CaveBoss"))
     {
         KillableGridObject killable = other.GetComponent <KillableGridObject>();
         if (killable && killList.Contains(killable))
         {
             killList.Remove(killable);
         }
     }
 }
コード例 #7
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (!other.isTrigger || other.GetComponent <PlantGridObject>() || other.CompareTag("CaveBoss"))
     {
         KillableGridObject killable = other.GetComponent <KillableGridObject>();
         if (killable)
         {
             killList.Add(killable);
         }
     }
 }
コード例 #8
0
 void OnTriggerExit2D(Collider2D other)
 {
     if ((!other.isTrigger || other.CompareTag("Ground")) && !other.CompareTag("Lava") && !other.CompareTag("Player") && other.isActiveAndEnabled)
     {
         nonLavaObjects--;
         KillableGridObject killable = other.GetComponent <KillableGridObject>();
         if (killable && killList.Contains(killable))
         {
             killList.Remove(killable);
         }
     }
 }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
    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;
        }
    }
コード例 #11
0
    public void KillSpawns()
    {
        for (int i = 0; i < spawnedMonsters.Count; i++)
        {
            if (spawnedMonsters[i] == null)
            {
                continue;
            }
            GameObject obj = spawnedMonsters[i];

            KillableGridObject spawn = obj.GetComponent <KillableGridObject>();
            Destroy(spawn.gameObject);
        }
        spawnedMonsters.Clear();
        currentSpawnCount = 0;
    }
コード例 #12
0
    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);
            }
        }
    }
コード例 #13
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (((other.CompareTag("Enemy") || (other.CompareTag("EnemySpawner"))) && !evil) || (evil && other.CompareTag("Player")))
     {
         KillableGridObject killable = other.GetComponent <KillableGridObject>();
         //null check
         if (killable)
         {
             if (!killable.isInvulnerable)
             {
                 triggered = killable;
                 if (canChangeDir)
                 {
                     if (other.IsTouching(southCollider.gameObject.GetComponent <BoxCollider2D>()))
                     {
                         direction    = Globals.Direction.South;
                         canChangeDir = false;
                         StartCoroutine(changeDirectionWait());
                     }
                     else if (other.IsTouching(northCollider.gameObject.GetComponent <BoxCollider2D>()))
                     {
                         direction    = Globals.Direction.North;
                         canChangeDir = false;
                         StartCoroutine(changeDirectionWait());
                     }
                     else if (other.IsTouching(eastCollider.gameObject.GetComponent <BoxCollider2D>()))
                     {
                         direction    = Globals.Direction.East;
                         canChangeDir = false;
                         StartCoroutine(changeDirectionWait());
                     }
                     else if (other.IsTouching(westCollider.gameObject.GetComponent <BoxCollider2D>()))
                     {
                         direction    = Globals.Direction.West;
                         canChangeDir = false;
                         StartCoroutine(changeDirectionWait());
                     }
                 }
             }
         }
     }
 }
コード例 #14
0
 void OnCollisionEnter2D(Collision2D coll) {
     KillableGridObject killable = coll.gameObject.GetComponent<KillableGridObject>();
     if (killable)
         killable.TakeDamage(damage);
 }