コード例 #1
0
ファイル: Player.cs プロジェクト: polytronicgr/UpvoidMiner
        /// <summary>
        /// Adds a drone at the given position.
        /// Does not remove any drone from the inventory.
        /// </summary>
        public void AddDrone(vec3 position)
        {
            Drone d = new Drone(position + new vec3(0, 1, 0), this, DroneType.Chain);

            Drones.Add(d);

            // Add drone to the first constraint it can be added to.
            bool foundConstraint = false;

            foreach (var dc in DroneConstraints)
            {
                if (dc.IsAddable(d))
                {
                    // Drone is addable, i.e. the constraint contains a drone of the same type
                    dc.AddDrone(d);
                    foundConstraint = true;
                    break;
                }
            }

            // If no constraint was found, we add a new one and add the drone to that.
            if (!foundConstraint)
            {
                DroneConstraints.Add(new DroneConstraint(d));
            }

            // Add the drone as new entity.
            ContainingWorld.AddEntity(d, mat4.Translate(d.CurrentPosition), Network.GCManager.CurrentUserID);
        }
コード例 #2
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)));
            }
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: polytronicgr/UpvoidMiner
        /// <summary>
        /// Drops an item.
        /// </summary>
        public void DropItem(Item item)
        {
            Item droppedItem = item.Clone();

            Inventory.RemoveItem(item);

            ItemEntity itemEntity = new ItemEntity(droppedItem);

            ContainingWorld.AddEntity(itemEntity, mat4.Translate(Position + vec3.UnitY * 1f + CameraDirection * 1f));
            itemEntity.ApplyImpulse(CameraDirection * 200f, new vec3(0, .3f, 0));
        }