예제 #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     //Add timer and modife to OnTrigger2D
     if (isServer && !npc && collision.CompareTag(ReferenceManager.Singleton.EnemyTag)) //If i'm not an npc and i collide with an enemy ship
     {
         hullHealth.ApplyChange(-collision.gameObject.GetComponentInParent <EnemyBase>().CollisionDamage);
     }
 }
예제 #2
0
 private void ServerCollisionHandler(Collision2D collision)
 {
     if (collision.gameObject.CompareTag(ReferenceManager.Singleton.SubmarineTag))
     {
         gold.ApplyChange(value);
         RemoveGold();
     }
 }
예제 #3
0
        protected virtual void OnEnable()
        {
            if (resource == null || textObject == null)
            {
                Debug.LogError(errorString);
                return;
            }

            InvokeRepeating(nameof(UpdateTextValue), 0, updateFrequency);

            if (isServer)
            {
                resource.ApplyChange(0);
            }
        }
예제 #4
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.CompareTag(ReferenceManager.Singleton.SubmarineTag) || collision.CompareTag(ReferenceManager.Singleton.EnemyTag))
            {
                bool alliedShip = (npc && collision.CompareTag(ReferenceManager.Singleton.EnemyTag)) || (!npc && collision.CompareTag(ReferenceManager.Singleton.SubmarineTag));

                if (debugCollision)
                {
                    string info = transform.name + " was hit by a ";
                    if (alliedShip)
                    {
                        Debug.Log(info + nameof(alliedShip));
                    }
                    else
                    {
                        Debug.Log(info + "enemy bullet");
                    }
                }

                if (!alliedShip)
                {
                    //TODO fix Bubba's health so that it's not null
                    //Todo change this if collider position is standardized
                    ShipResource health = collision.gameObject.GetComponent <ShipResource>();

                    if (health == null)
                    {
                        health = collision.gameObject.GetComponentInParent <ShipResource>();
                    }

                    if (debugCollision && health == null)
                    {
                        Debug.Log("Health is null");
                    }

                    if (debugCollision)
                    {
                        Debug.Log("Damage is: " + damage + "\nHealth before: " + health.CurrentValue);
                    }

                    health.ApplyChange(-Damage);

                    if (debugCollision)
                    {
                        Debug.Log("Health after: " + health.CurrentValue);
                    }

                    if (npc && health.CurrentValue == 0)
                    {
                        NetworkServer.Destroy(collision.gameObject);
                    }
                }
            }

            if (isServer)
            {
                ServerPlaySound();
            }
            else
            {
                CommandPlaySound();
            }

            NetworkServer.Destroy(gameObject);
        }
예제 #5
0
 protected override void DecreaseTime()
 {
     oxygenSeconds.ApplyChange(-GetConsumption());
     base.DecreaseTime();
 }
예제 #6
0
 [Server] protected virtual void DecreaseTime() => shipResource.ApplyChange(-decreaseAmount);