Exemplo n.º 1
0
        public void Hit(object message)
        {
            if (!(message is HitMessage))
            {
                return;
            }

            // Tree has been hit (by an axe), so we create some wood cylinders the player can pick up

            ContainingWorld.RemoveEntity(thisEntity);

            // Gather wood from "real" trees only, not from cacti etc.
            if (treeType != TreeType.Birch)
            {
                return;
            }

            int numberOfWoodCylinders = 3 * (int)(amountOfWood + 1.0f);

            for (int i = 0; i < numberOfWoodCylinders; ++i)
            {
                ItemEntity itemEntity = new ItemEntity(new MaterialItem(TerrainResource.FromName("BirchWood"), MaterialShape.Cylinder, new vec3(0.2f, 0.7f, 0.2f)));
                ContainingWorld.AddEntity(itemEntity, mat4.Translate(Position + new vec3(0, 1 + i, 0)));
            }
        }
Exemplo n.º 2
0
        public void Interaction(object msg)
        {
            // Make sure we get the message type we are expecting.
            InteractionMessage interactionMsg = msg as InteractionMessage;

            if (interactionMsg == null)
            {
                return;
            }

            // Interacting with an item means picking it up. Answer by sending the item to the sender.
            interactionMsg.Sender[AddItemTrigger] |= new AddItemMessage(RepresentedItem);

            // And remove this entity.
            ContainingWorld.RemoveEntity(thisEntity);
        }
Exemplo n.º 3
0
        public void Interaction(object msg)
        {
            // Make sure we get the message type we are expecting.
            InteractionMessage interactionMsg = msg as InteractionMessage;

            if (interactionMsg == null)
            {
                return;
            }

            // Interacting with an item means picking it up. Answer by sending the item to the sender.
            interactionMsg.Sender[AddItemTrigger] |= new AddItemMessage(new ToolItem(ToolType.DroneChain));

            // Remove drone from drone constraints.
            Owner.RemoveDrone(this);
            // And remove this entity.
            ContainingWorld.RemoveEntity(thisEntity);
        }