Пример #1
0
    private void die()
    {
        foreach (DeathCallback callback in this.OnDeathCallbacks)
            callback(this);

        if (this.GibsPoolKey != null && this.GibsPoolKey != "")
        {
            GameObject gibs = ObjectPools.GetPooledObject(this.GibsPoolKey);
            gibs.transform.position = this.transform.position;
            gibs.transform.rotation = this.transform.rotation;
            GibsBehavior gibsBehavior = gibs.GetComponent<GibsBehavior>();
            gibsBehavior.Knockback = _deathKnockback;
            gibsBehavior.ImpactVector = _deathImpactVector;
            AllegianceColorizer colorizer = this.GetComponent<AllegianceColorizer>();
            if (colorizer != null)
            {
                gibsBehavior.AllegianceInfo = colorizer.AllegianceInfo;
            }
        }

        if (this.ShakeMagnitudeOnDeath > 0.0f)
            Camera.main.GetComponent<ShakeHandler>().ApplyImpact(this.ShakeMagnitudeOnDeath);

        Destroy(this.gameObject);
    }
Пример #2
0
    public static void CreateExplosionEntity(Vector3 position, string explosionKey, AllegianceInfo allegianceInfo, int layer, LayerMask damagableLayers, WeaponType weaponType)
    {
        GameObject explosion = ObjectPools.GetPooledObject(explosionKey);

        explosion.transform.position = position;
        explosion.GetComponent <Explosion>().DetonateWithWeaponType(weaponType, layer, damagableLayers, allegianceInfo);
    }
Пример #3
0
 private void createBullet(Vector2 direction, float shotStartDistance, string bulletKey, bool ignoreExplosions)
 {
     if (!this.RaycastToShotStart || !CollisionManager.RaycastFirst((Vector2)this.transform.position, direction, shotStartDistance, this.ShotBlockMask).Collided)
     {
         // Create instance of bullet prefab and set it on its way
         Vector3    position = this.transform.position + (Vector3)(direction * shotStartDistance);
         GameObject bullet   = ObjectPools.GetPooledObject(bulletKey);
         bullet.transform.position = position;
         bullet.GetComponent <Bullet>().LaunchWithWeaponType(direction, this.WeaponType, this.AllegianceInfo, ignoreExplosions);
     }
 }
Пример #4
0
    public void OnLaserCast(LocalEventNotifier.Event localEvent)
    {
        LaserCastEvent castEvent = (LaserCastEvent)localEvent;

        CollisionManager.RaycastResult raycast = castEvent.RaycastResult;

        IntegerVector distance = raycast.FarthestPointReached - castEvent.Origin;

        if (distance.X == 0 && distance.Y == 0)
        {
            return;
        }

        GameObject lineObject = ObjectPools.GetPooledObject(this.LineObjectKey);

        _lineObjects.Add(lineObject);
        //lineObject.transform.parent = this.transform;
        lineObject.transform.position = new Vector3(castEvent.Origin.X, castEvent.Origin.Y, this.transform.position.z);

        lineObject.GetComponent <LineRenderer>().SetPosition(1, new Vector3(raycast.FarthestPointReached.X - castEvent.Origin.X, raycast.FarthestPointReached.Y - castEvent.Origin.Y, 0));
        lineObject.GetComponent <AllegianceColorizer>().UpdateVisual(castEvent.AllegianceInfo);
    }