Пример #1
0
 // TODO: Right now, when the head is struck nothing happens. This will need fixed and this function below called when it is struck
 public void OnStrikeHeadWithGameObject(GameObject whoIsStriking, GameObject whatIsBeingUsedToStrike, float howMuchDamage)
 {
     // Add the enemy to our percieved threats automatically if they do something aggressive
     gameObjectsPercievedAsThreat.Add(whoIsStriking);
     // TODO: Set this up so creatures can handle fighting multiple hostiles
     gameObjectKnownToBeHostile = whoIsStriking;
     // If the boar was sleeping, it's awake now!
     identifier.descriptiveAdjectives.Remove("sleeping");
     // Go into attacking state
     AIState = AIStates.ATTACKING;
     // Forward the damage to the head
     head.specialProperties["health"] = (float.Parse(head.specialProperties["health"], System.Globalization.CultureInfo.InvariantCulture) - howMuchDamage).ToString();
     // Create a message entailing our action and send it to nearby players
     Support.Networking.RPCs.RPCSay message = new Support.Networking.RPCs.RPCSay();
     // Add bleeding effect if object being used to strike is sharp
     if (whatIsBeingUsedToStrike.identifier.descriptiveAdjectives.Contains("sharp"))
     {
         head.specialProperties["isBleeding"] = "TRUE";
         message.arguments.Add("The " + identifier.fullName + " now has " + head.specialProperties["health"] + " head health! The flesh is pierced and bleeding!");
         // Notify everyone
         attachedApplication.server.world.SendMessageToPosition(
             "The " + identifier.fullName + " now has " + head.specialProperties["health"] + " head health! The flesh is pierced and bleeding!",
             position);
     }
     else
     {
         // Notify everyone
         attachedApplication.server.world.SendMessageToPosition(
             "The " + identifier.fullName + " now has " + head.specialProperties["health"] + " head health!",
             position);
     }
 }
Пример #2
0
        // Sends one message to every at position
        public void SendMessageToPosition(string message, Position position)
        {
            // Create a message entailing our action and send it to nearby players
            Support.Networking.RPCs.RPCSay messageToEveryoneRPC = new Support.Networking.RPCs.RPCSay();
            messageToEveryoneRPC.arguments.Add(message);

            // Get the nearby players to notify them our action
            foreach (KeyValuePair <string, Core.Player> playerEntry in attachedApplication.server.world.players)
            {
                // If this player is in our chunk
                if (playerEntry.Value.controlledGameObject.position == position)
                {
                    // Send an informational RPC to them letting them know
                    attachedApplication.server.SendRPC(messageToEveryoneRPC, playerEntry.Key);
                }
            }
        }