Beispiel #1
0
    public IEnumerator KineticAnim(Collision2D coll)
    {
        Transform   cellTransform = rigidBody.gameObject.transform;
        MetaTileMap layerMetaTile = cellTransform.GetComponentInParent <MetaTileMap>();

        ContactPoint2D firstContact = coll.GetContact(0);
        Vector3        hitPos       = firstContact.point;
        Vector3        forceDir     = Direction;

        forceDir.z = 0;
        Vector3    bulletHitTarget = hitPos + (forceDir * 0.2f);
        Vector3Int cellPos         = layerMetaTile.WorldToCell(Vector3Int.RoundToInt(bulletHitTarget));

        TileChangeManager tileChangeManager = transform.GetComponentInParent <TileChangeManager>();

        // Store the old effect
        LayerTile oldEffectLayerTile = tileChangeManager.GetLayerTile(cellPos, LayerType.Effects);

        tileChangeManager.UpdateTile(cellPos, TileType.Effects, "KineticAnimation");

        yield return(WaitFor.Seconds(.4f));

        tileChangeManager.RemoveTile(cellPos, LayerType.Effects);

        // Restore the old effect if any (ex: cracked glass, does not work)
        if (oldEffectLayerTile)
        {
            tileChangeManager.UpdateTile(cellPos, oldEffectLayerTile);
        }
        isOnDespawn = false;
        Despawn.ClientSingle(gameObject);
    }
Beispiel #2
0
    private IEnumerator FadeIcon()
    {
        float timer = 0f;
        float time  = 0.1f;

        while (timer <= time)
        {
            timer += Time.deltaTime;
            float lerpProgress = timer / time;
            spriteRenderer.color    = Color.Lerp(transparent, visible, lerpProgress);
            transform.localPosition = Vector3.Lerp(lerpFrom, lerpTo, lerpProgress / 2f);
            yield return(WaitFor.EndOfFrame);
        }
        lerpFrom = transform.localPosition;
        timer    = 0f;
        time     = 0.2f;

        while (timer <= time)
        {
            timer += Time.deltaTime;
            float lerpProgress = timer / time;
            spriteRenderer.color    = Color.Lerp(visible, transparent, lerpProgress);
            transform.localPosition = Vector3.Lerp(lerpFrom, lerpTo, lerpProgress);
            yield return(WaitFor.EndOfFrame);
        }
        spriteRenderer.sprite = null;
        Despawn.ClientSingle(gameObject);
    }
Beispiel #3
0
    public IEnumerator KineticAnim()
    {
        Transform   cellTransform = rigidBody.gameObject.transform;
        MetaTileMap layerMetaTile = cellTransform.GetComponentInParent <MetaTileMap>();
        var         position      = layerMetaTile.WorldToCell(Vector3Int.RoundToInt(rigidBody.gameObject.AssumedWorldPosServer()));

        TileChangeManager tileChangeManager = transform.GetComponentInParent <TileChangeManager>();

        // Store the old effect
        LayerTile oldEffectLayerTile = tileChangeManager.GetLayerTile(position, LayerType.Effects);

        tileChangeManager.UpdateTile(position, TileType.Effects, "KineticAnimation");

        yield return(WaitFor.Seconds(.4f));

        tileChangeManager.RemoveTile(position, LayerType.Effects);

        // Restore the old effect if any (ex: cracked glass, does not work)
        if (oldEffectLayerTile)
        {
            tileChangeManager.UpdateTile(position, oldEffectLayerTile);
        }
        isOnDespawn = false;
        Despawn.ClientSingle(gameObject);
    }
Beispiel #4
0
 public void CleanTile()
 {
     if (fireScorch != null)
     {
         fireScorch.transform.parent = null;
         Despawn.ClientSingle(fireScorch);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Despawn bullet and call all
 /// on despawn behaviours
 /// </summary>
 private void DespawnThis(RaycastHit2D hit, Vector2 point)
 {
     foreach (var behaviour in behavioursOnBulletDespawn)
     {
         behaviour.OnDespawn(hit, point);
     }
     Despawn.ClientSingle(gameObject);
 }
 protected virtual void DespawnThis()
 {
     if (trailRenderer != null)
     {
         trailRenderer.ShotDone();
     }
     rigidBody.velocity = Vector2.zero;
     Despawn.ClientSingle(gameObject);
 }
Beispiel #7
0
 private void ReturnToPool()
 {
     if (trailRenderer != null)
     {
         trailRenderer.ShotDone();
     }
     rigidBody.velocity = Vector2.zero;
     Despawn.ClientSingle(gameObject);
 }
Beispiel #8
0
 //Ran out of fuel, return to pool
 private void BurntOut()
 {
     // TODO burn tiles
     //		FloorTile fT = MatrixOld.Matrix.At((Vector2)transform.position).GetFloorTile();
     //		if (fT != null) {
     //			fT.AddFireScorch();
     //		}
     Despawn.ClientSingle(gameObject);
 }
 private void UpdateMe()
 {
     currentTime += Time.deltaTime;
     if (currentTime >= lifeTime)
     {
         currentTime = 0;
         spriteHandler.PushClear(false);
         Despawn.ClientSingle(gameObject);
     }
 }
 /// <summary>
 /// Break the closet lock.
 /// </summary>
 public void BreakLock()
 {
     //Disable the lock and hide its light
     if (IsLockable)
     {
         SyncLocked(isLocked, false);
         IsLockable = false;
         lockLight.Hide();
         Despawn.ClientSingle(lockOverlay);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Despawn bullet and call all
        /// on despawn behaviours
        /// </summary>
        private void DespawnThis(MatrixManager.CustomPhysicsHit hit, Vector2 point)
        {
            foreach (var behaviour in behavioursOnBulletDespawn)
            {
                behaviour.OnDespawn(hit, point);
            }

            if (CustomNetworkManager.IsServer)
            {
                _ = Despawn.ServerSingle(gameObject);
            }
            else
            {
                if (Despawn.ClientSingle(gameObject).Successful == false)
                {
                    Destroy(gameObject);
                }
            }
        }
Beispiel #12
0
        private void ShootBeam(Vector2 direction, GameObject controlledByPlayer, Gun fromWeapon, BodyPartType targetZone)
        {
            foreach (var behaviour in behavioursOnShoot)
            {
                behaviour.OnShoot(direction, controlledByPlayer, fromWeapon, targetZone);
            }

            var     pos      = transform.position;
            Vector3 startPos = new Vector3(direction.x, direction.y, pos.z) * 0.7f;
            var     hit      = Physics2D.Raycast(pos + startPos, direction, distance - 1, maskData.Layers);

            var dis = ((Vector2)pos + (direction * distance));

            foreach (var behaviour in behavioursOnBulletDespawn)
            {
                behaviour.OnDespawn(hit, dis);
            }

            Despawn.ClientSingle(gameObject);
        }