예제 #1
0
        //TODO: Remove this when atmos is implemented
        //This prevents players drifting into space indefinitely
        private IEnumerator ApplyTempSpaceDamage()
        {
            yield return(new WaitForSeconds(1f));

            healthBehaviorScript.RpcApplyDamage(null, 5, DamageType.OXY, BodyPartType.HEAD);
            //No idea why there is an isServer catch on RpcApplyDamage, but will apply on server as well in mean time:
            healthBehaviorScript.ApplyDamage(null, 5, DamageType.OXY, BodyPartType.HEAD);
            isApplyingSpaceDmg = false;
        }
    [Command] //TODO fixme ghetto proof-of-concept
    public void CmdKnifeAttackMob(GameObject npcObj, GameObject weapon, Vector2 stabDirection, BodyPartType damageZone)
    {
        HealthBehaviour healthBehaviour = npcObj.GetComponent <HealthBehaviour>();

        if (healthBehaviour.IsDead == false)
        {
            if (!playerMove.allowInput || !allowAttack || playerMove.isGhost)
            {
                return;
            }

            if (npcObj != gameObject)
            {
                RpcMeleAttackLerp(stabDirection, weapon);
            }

            healthBehaviour
            .ApplyDamage(gameObject.name, 20, DamageType.BRUTE, damageZone);

            //this crap will remain here until moved to netmessages
            healthBehaviour.RpcApplyDamage(gameObject.name, 20, DamageType.BRUTE, damageZone);

            soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            StartCoroutine(AttackCoolDown());
        }
        else
        {
            if (!playerMove.allowInput || playerMove.isGhost)
            {
                return;
            }
            if (npcObj.GetComponent <SimpleAnimal>())
            {
                SimpleAnimal attackTarget = npcObj.GetComponent <SimpleAnimal>();
                RpcMeleAttackLerp(stabDirection, weapon);
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
            else
            {
                PlayerHealth attackTarget = npcObj.GetComponent <PlayerHealth>();
                RpcMeleAttackLerp(stabDirection, weapon);
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
        }
    }