[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);
            }
        }
    }
Exemplo n.º 2
0
    public void CmdKnifeAttackMob(GameObject npcObj, Vector2 stabDirection)
    {
        if (!playerMove.allowInput || !allowAttack || playerMove.isGhost)
        {
            return;
        }

        Living attackTarget = npcObj.GetComponent <Living>();

        if (npcObj != gameObject)
        {
            RpcKnifeAttackLerp(stabDirection);
        }
        attackTarget.RpcReceiveDamage(gameObject.name, 20, DamageType.BRUTE, BodyPartType.CHEST);
        BloodSplat(npcObj.transform.position, BloodSplatSize.medium);
        soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);

        StartCoroutine(AttackCoolDown());
    }
Exemplo n.º 3
0
    [Command]//TODO fixme ghetto proof-of-concept
    public void CmdKnifeAttackMob(GameObject npcObj, Vector2 stabDirection, BodyPartType damageZone)
    {
        if (!playerMove.allowInput || !allowAttack || playerMove.isGhost)
        {
            return;
        }

        if (npcObj != gameObject)
        {
            RpcKnifeAttackLerp(stabDirection);
        }
        var healthBehaviour = npcObj.GetComponent <HealthBehaviour>();

        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());
    }
Exemplo n.º 4
0
    public void OnConsciousStateChanged(ConsciousState oldState, ConsciousState newState)
    {
        switch (newState)
        {
        case ConsciousState.CONSCIOUS:
            playerMove.allowInput = true;
            playerScript.PlayerSync.SpeedServer = playerMove.RunSpeed;
            break;

        case ConsciousState.BARELY_CONSCIOUS:
            //Drop items when unconscious
            DropItem("rightHand");
            DropItem("leftHand");
            playerMove.allowInput = true;
            playerScript.PlayerSync.SpeedServer = playerMove.CrawlSpeed;
            if (oldState == ConsciousState.CONSCIOUS)
            {
                //only play the sound if we are falling
                soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
            }
            break;

        case ConsciousState.UNCONSCIOUS:
            //Drop items when unconscious
            DropItem("rightHand");
            DropItem("leftHand");
            playerMove.allowInput = false;
            if (oldState == ConsciousState.CONSCIOUS)
            {
                //only play the sound if we are falling
                soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
            }
            break;
        }
        playerScript.pushPull.CmdStopPulling();
    }
Exemplo n.º 5
0
    /// <summary>
    /// Rotate player and play body fall sound
    /// </summary>
    private void Fall()
    {
        ForceRotation rotation = gameObject.GetComponent <ForceRotation>();

        if (rotation.Rotation == FALLEN)
        {
//			Logger.LogTrace( "Not dropping fallen player again", Category.Health );
            return;
        }
        rotation.Rotation = FALLEN;
        soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
        if (Random.value > 0.5f)
        {
            playerSprites.currentDirection = Orientation.Up;
        }
    }
Exemplo n.º 6
0
 public void CmdConsciousState(bool conscious)
 {
     if (conscious)
     {
         playerMove.allowInput = true;
         RpcSetPlayerRot(false, 0f);
     }
     else
     {
         playerMove.allowInput = false;
         RpcSetPlayerRot(false, -90f);
         soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
         if (Random.value > 0.5f)
         {
             playerSprites.currentDirection = Vector2.up;
         }
     }
 }
Exemplo n.º 7
0
 public void SetConsciousState(bool conscious)
 {
     if (conscious)
     {
         playerMove.allowInput = true;
         gameObject.GetComponent <ForceRotation>().Rotation = new Vector3(0, 0, 0);
     }
     else
     {
         playerMove.allowInput = false;
         gameObject.GetComponent <ForceRotation>().Rotation = new Vector3(0, 0, -90);
         soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
         if (Random.value > 0.5f)
         {
             playerSprites.currentDirection = Orientation.Up;
         }
     }
     playerScript.pushPull.CmdStopPulling();
 }
Exemplo n.º 8
0
    public void SetConsciousState(bool conscious)
    {
        //Store the server conscious state for this player:
        playerScript.playerHealth.serverPlayerConscious = conscious;

        if (conscious)
        {
            playerMove.allowInput = true;
            playerSprites.RpcSetPlayerRot(0f);
        }
        else
        {
            playerMove.allowInput = false;
            playerSprites.RpcSetPlayerRot(-90f);
            soundNetworkActions.RpcPlayNetworkSound("Bodyfall", transform.position);
            if (Random.value > 0.5f)
            {
                playerSprites.currentDirection = Orientation.Up;
            }
        }
    }
Exemplo n.º 9
0
    public void CmdRequestMeleeAttack(GameObject victim, string slot, Vector2 stabDirection, BodyPartType damageZone)
    {
        if (!playerMove.allowInput ||
            playerMove.isGhost ||
            !victim ||
            !playerScript.playerNetworkActions.SlotNotEmpty(slot) ||
            !PlayerManager.PlayerInReach(victim.transform)
            )
        {
            return;
        }
        var             weapon       = playerScript.playerNetworkActions.Inventory[slot];
        ItemAttributes  weaponAttr   = weapon.GetComponent <ItemAttributes>();
        HealthBehaviour victimHealth = victim.GetComponent <HealthBehaviour>();


        // checks object and component existence before defining healthBehaviour variable.
        if (victimHealth.IsDead == false)
        {
            if (!allowAttack)
            {
                return;
            }

            if (victim != gameObject)
            {
                RpcMeleeAttackLerp(stabDirection, weapon);
            }

            victimHealth.ApplyDamage(gameObject, ( int )weaponAttr.hitDamage, DamageType.BRUTE, damageZone);
            if (weaponAttr.hitDamage > 0)
            {
                PostToChatMessage.SendItemAttackMessage(weapon, gameObject, victim, (int)weaponAttr.hitDamage, damageZone);
            }

            soundNetworkActions.RpcPlayNetworkSound(weaponAttr.hitSound, transform.position);
            StartCoroutine(AttackCoolDown());
        }
        else
        {
            //Butchering if we can
            if (weaponAttr.type != ItemType.Knife)
            {
                return;
            }
            if (victim.GetComponent <SimpleAnimal>())
            {
                SimpleAnimal attackTarget = victim.GetComponent <SimpleAnimal>();
                RpcMeleeAttackLerp(stabDirection, weapon);
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
            else
            {
                PlayerHealth attackTarget = victim.GetComponent <PlayerHealth>();
                RpcMeleeAttackLerp(stabDirection, weapon);
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
        }
    }
Exemplo n.º 10
0
    public void CmdRequestMeleeAttack(GameObject victim, string slot, Vector2 stabDirection,
                                      BodyPartType damageZone, LayerType layerType)
    {
        if (!playerMove.allowInput ||
            playerMove.isGhost ||
            !victim ||
            !playerScript.playerNetworkActions.SlotNotEmpty(slot) ||
            !playerScript.playerHealth.serverPlayerConscious
            )
        {
            return;
        }
        if (!allowAttack)
        {
            return;
        }

        var            weapon     = playerScript.playerNetworkActions.Inventory[slot].Item;
        ItemAttributes weaponAttr = weapon.GetComponent <ItemAttributes>();

        // If Tilemap LayerType is not None then it is a tilemap being attacked
        if (layerType != LayerType.None)
        {
            TileChangeManager tileChangeManager = victim.GetComponent <TileChangeManager>();
            MetaTileMap       metaTileMap       = victim.GetComponentInChildren <MetaTileMap>();
            if (tileChangeManager == null)
            {
                return;
            }

            //Tilemap stuff:
            var tileMapDamage = metaTileMap.Layers[layerType].GetComponent <TilemapDamage>();
            if (tileMapDamage != null)
            {
                //Wire cutters should snip the grills instead:
                if (weaponAttr.itemName == "wirecutters" &&
                    tileMapDamage.Layer.LayerType == LayerType.Grills)
                {
                    tileMapDamage.WireCutGrill((Vector2)transform.position + stabDirection);
                    StartCoroutine(AttackCoolDown());
                    return;
                }

                tileMapDamage.DoMeleeDamage((Vector2)transform.position + stabDirection,
                                            gameObject, (int)weaponAttr.hitDamage);

                playerMove.allowInput = false;
                RpcMeleeAttackLerp(stabDirection, weapon);
                StartCoroutine(AttackCoolDown());
                return;
            }
            return;
        }

        //This check cannot be used with TilemapDamage as the transform position is always far away
        if (!playerScript.IsInReach(victim))
        {
            return;
        }

        //Meaty bodies:
        LivingHealthBehaviour victimHealth = victim.GetComponent <LivingHealthBehaviour>();

        if (victimHealth.IsDead && weaponAttr.type == ItemType.Knife)
        {
            if (victim.GetComponent <SimpleAnimal>())
            {
                SimpleAnimal attackTarget = victim.GetComponent <SimpleAnimal>();
                RpcMeleeAttackLerp(stabDirection, weapon);
                playerMove.allowInput = false;
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
            else
            {
                PlayerHealth attackTarget = victim.GetComponent <PlayerHealth>();
                RpcMeleeAttackLerp(stabDirection, weapon);
                playerMove.allowInput = false;
                attackTarget.Harvest();
                soundNetworkActions.RpcPlayNetworkSound("BladeSlice", transform.position);
            }
            return;
        }

        if (victim != gameObject)
        {
            RpcMeleeAttackLerp(stabDirection, weapon);
            playerMove.allowInput = false;
        }

        victimHealth.ApplyDamage(gameObject, (int)weaponAttr.hitDamage, DamageType.Brute, damageZone);
        if (weaponAttr.hitDamage > 0)
        {
            PostToChatMessage.SendItemAttackMessage(weapon, gameObject, victim, (int)weaponAttr.hitDamage, damageZone);
        }

        soundNetworkActions.RpcPlayNetworkSound(weaponAttr.hitSound, transform.position);
        StartCoroutine(AttackCoolDown());
    }