Ejemplo n.º 1
0
        // Melee
        void OnTriggerEnter(Collider theColliderWeHit)
        {
            // Add hits to a list to prevent damage stacking in the same swing.
            // Empty the list when swing finishes.
            if (_hitsDuringThisSwing.Contains(theColliderWeHit))
            {
                return;
            }

            _victimGameObject = theColliderWeHit.gameObject;
            _victimSubject    = _victimGameObject.GetComponent <Subject>();

            Vector3 impactPos = theColliderWeHit.transform.position + Vector3.up; // would be nice to get more accurate with this.

            // if what we hit is on a layer in our mask, plow into it.
            if (!StaticUtil.LayerMatchTest(Mask, _victimGameObject))
            {
                return;
            }
            if (_victimSubject != null)
            {
                DoMeleeDamage(theColliderWeHit.GetComponent <Subject>());
            }

            DoMeleeDamage(theColliderWeHit.GetComponent <Subject>());
            DoImpactEffects(impactPos);
            _hitsDuringThisSwing.Add(theColliderWeHit);
        }
Ejemplo n.º 2
0
        void OnTriggerEnter(Collider col)
        {
            if (_started || !StaticUtil.LayerMatchTest(CanUseThis, col.gameObject))
            {
                return;
            }
            _started = true;

            int i = 0;

            if (SpawnPoints.Length == 0)
            {
                Debug.LogWarning("Spawn Trigger Warning: No spawn points are specified so this trigger effectively does nothing.");
                return;
            }
            foreach (GameObject point in SpawnPoints)
            {
                if (!SpawnerPrefabs[i])
                {
                    Debug.LogError("Spawn Trigger Error: You specify a spawn point, but no Spawner Prefab. Can't proceed without a valid Prefab of the Spawner that you to create.");
                    break;
                }
                GameObject s = (GameObject)StaticUtil.Spawn(SpawnerPrefabs[i], point.transform.position, point.transform.rotation);
                Spawner    x = s.GetComponent <Spawner>();
                _remainingSpawners.Add(x);
                x.Owner = this;
                i++;
            }

            StartCoroutine(CloseDoors());
            StartCoroutine(VictoryLoop());
        }
Ejemplo n.º 3
0
 void OnTriggerExit(Collider col)
 {
     if (ManuallyTriggered || Locked || !DoorMesh)
     {
         return;
     }
     if (!StaticUtil.LayerMatchTest(CanUseThisDoor, col.gameObject))
     {
         return;
     }
     _occupancy--;
 }
Ejemplo n.º 4
0
        void OnTriggerEnter(Collider col)
        {
            if (!StaticUtil.LayerMatchTest(CanPickThisUp, col.gameObject))
            {
                return;
            }
            _subject  = col.GetComponent <Subject>();
            _controls = col.GetComponent <PlayerController>();
            if (_subject == null || _controls == null)
            {
                return;
            }

            _canPickup = true;
        }
Ejemplo n.º 5
0
        void OnCollisionEnter2D(Collision2D col) // Handles hits for Standard Type.
        {
            if (!Stats.CauseAoeDamage)           // I cause damage to what I collided into.
            {
                _victimGo = col.gameObject;
                _victim   = _victimGo.GetComponent <Subject>();

                if (StaticUtil.LayerMatchTest(Mask, _victimGo))
                {
                    if (_victim != null)
                    {
                        DoDamageToVictim();
                    }

                    _endPoint = col.contacts[0].point;
                    SetupImpactNormal(col.contacts[0].normal);
                    PopFx(GetCorrectFx(col.gameObject));
                    if (_endNormal != null)
                    {
                        _victim.ShowHitIndicator(_endNormal);
                    }
                    FinishImpact(); -------------------------------------------------------------------------------------------------------- ö - pöpö
                }
                else
                {
                    foreach (Collider2D z in _myColliders)
                    {
                        Physics2D.IgnoreCollision(z, col.collider);
                    }
                }
            }
            else if (Stats.CauseAoeDamage && !Stats.Bouncer)
            {
                DoDamageAoe();                                              // I cause AoE immediately when I hit something.
            }
        }
Ejemplo n.º 6
0
        void OnTriggerEnter(Collider col)
        {
            _collector = col.gameObject;
            if (!StaticUtil.LayerMatchTest(Mask, _collector))
            {
                return;
            }
            _keeper = col.GetComponent <Subject>();
            if (_keeper == null)
            {
                return;
            }

            if (TargetStat == Target.Health)
            {
                switch (Act)
                {
                case ActionType.Add:
                {
                    _keeper.Health += Value;
                    break;
                }

                case ActionType.Subtract:
                {
                    _keeper.Health -= Value;
                    break;
                }

                case ActionType.Set:
                {
                    _keeper.Health = Value;
                    break;
                }
                }
            }

            if (TargetStat == Target.Armor)
            {
                switch (Act)
                {
                case ActionType.Add:
                {
                    _keeper.Armor += Value;
                    break;
                }

                case ActionType.Subtract:
                {
                    _keeper.Armor -= Value;
                    break;
                }

                case ActionType.Set:
                {
                    _keeper.Armor = Value;
                    break;
                }
                }
            }

            if (TargetStat == Target.Ammo)
            {
                if (Pickup == PickupAffect.Current)
                {
                    Weapon w = _keeper.GetCurrentWeaponComponent();
                    AffectWeaponAmmo(w);
                }
                else
                {
                    foreach (GameObject wpn in _keeper.WeaponListRuntime)
                    {
                        Weapon w = wpn.GetComponent <Weapon>();
                        AffectWeaponAmmo(w);
                    }
                }
            }

            if (TargetStat == Target.Magazines)
            {
                if (Pickup == PickupAffect.Current)
                {
                    Weapon w = _keeper.GetCurrentWeaponComponent();
                    AffectWeaponMags(w);
                }
                else
                {
                    foreach (GameObject wpn in _keeper.WeaponListRuntime)
                    {
                        Weapon w = wpn.GetComponent <Weapon>();
                        AffectWeaponMags(w);
                    }
                }
            }

            _keeper.DoGrabPowerup();
            Disappear();
        }