private void damageUpdate()
    {
        // damage a players if they out of the blue area every second
        if (Time.time >= dmTimeTmp + 1)
        {
            for (int i = 0; i < allPlayer.Length; i++)
            {
                if (allPlayer[i] != null)
                {
                    CharacterSystem player = allPlayer[i].GetComponent <CharacterSystem>();
                    if (player != null)
                    {
                        if (lastDeadArea != null && lastDeadArea.activeSelf)
                        {
                            Vector3 playerPos = player.transform.position;
                            playerPos.y = 0;
                            Vector3 deadAreaPos = lastDeadArea.transform.position;
                            deadAreaPos.y = 0;

                            float distance = Vector3.Distance(player.transform.position, lastDeadArea.transform.position);
                            if (distance > (lastDeadArea.transform.localScale.x / 2.0f))
                            {
                                // apply damage 1 to player
                                player.ApplyDamage(currentAreaDamage, Vector3.up, -1, 0);
                            }
                        }
                    }
                }
            }
            dmTimeTmp = Time.time;
        }
    }
Beispiel #2
0
    public void stomachUpdate()
    {
        if (isServer)
        {
            if (character == null || (character && !character.IsAlive))
            {
                return;
            }

            if (Water <= 0)
            {
                character.ApplyDamage(2, Vector3.up, character.NetID, 0);
            }
            if (Hungry <= 0)
            {
                character.ApplyDamage(1, Vector3.up, character.NetID, 0);
            }
        }
    }