コード例 #1
0
        public void Update(DwarfTime gameTime, GameMaster player)
        {
            if (!IsEnabled)
            {
                if (CurrentCraftBody != null)
                {
                    CurrentCraftBody.Delete();
                    CurrentCraftBody = null;
                }
                return;
            }

            if (Faction == null)
            {
                Faction = player.Faction;
            }

            if (CurrentCraftType != null && CurrentCraftBody == null)
            {
                CurrentCraftBody = EntityFactory.CreateEntity <Body>(CurrentCraftType.Name, player.VoxSelector.VoxelUnderMouse.Position);
                CurrentCraftBody.SetActiveRecursive(false);
                CurrentDesignation = new CraftDesignation()
                {
                    ItemType = CurrentCraftType,
                    Location = new Voxel(new Point3(0, 0, 0), null)
                };
                SetDisplayColor(Color.Green);
            }

            if (CurrentCraftBody == null || player.VoxSelector.VoxelUnderMouse == null)
            {
                return;
            }

            CurrentCraftBody.LocalPosition   = player.VoxSelector.VoxelUnderMouse.Position + Vector3.One * 0.5f;
            CurrentCraftBody.GlobalTransform = CurrentCraftBody.LocalTransform;
            CurrentCraftBody.OrientToWalls();

            if (CurrentDesignation.Location.IsSameAs(player.VoxSelector.VoxelUnderMouse))
            {
                return;
            }

            CurrentDesignation.Location = new Voxel(player.VoxSelector.VoxelUnderMouse);

            SetDisplayColor(IsValid(CurrentDesignation) ? Color.Green : Color.Red);
        }
コード例 #2
0
        public void Update(DwarfTime gameTime, GameMaster player)
        {
            if (!IsEnabled)
            {
                if (CurrentCraftBody != null)
                {
                    CurrentCraftBody.Delete();
                    CurrentCraftBody = null;
                }

                return;
            }

            if (Faction == null)
            {
                Faction = player.Faction;
            }

            if (CurrentCraftType != null && CurrentCraftBody == null)
            {
                CurrentCraftBody = EntityFactory.CreateEntity <Body>(CurrentCraftType.Name,
                                                                     player.VoxSelector.VoxelUnderMouse.WorldPosition,
                                                                     Blackboard.Create <List <ResourceAmount> >("Resources", SelectedResources));
                EntityFactory.GhostEntity(CurrentCraftBody, Color.White);

                CurrentDesignation = new CraftDesignation()
                {
                    ItemType = CurrentCraftType,
                    Location = VoxelHandle.InvalidHandle,
                    Valid    = true
                };

                OverrideOrientation = false;
                CurrentCraftBody.SetTintRecursive(Color.Green);
            }

            if (CurrentCraftBody == null || !player.VoxSelector.VoxelUnderMouse.IsValid)
            {
                return;
            }

            CurrentCraftBody.LocalPosition = player.VoxSelector.VoxelUnderMouse.WorldPosition + new Vector3(0.5f, 0.0f, 0.5f) + CurrentCraftType.SpawnOffset;

            CurrentCraftBody.GlobalTransform = CurrentCraftBody.LocalTransform;
            CurrentCraftBody.UpdateTransform();
            CurrentCraftBody.PropogateTransforms();
            if (OverrideOrientation)
            {
                CurrentCraftBody.Orient(CurrentOrientation);
            }
            else
            {
                CurrentCraftBody.OrientToWalls();
            }

            HandleOrientation();

            if (CurrentDesignation != null)
            {
                if (CurrentDesignation.Location.Equals(player.VoxSelector.VoxelUnderMouse))
                {
                    return;
                }

                CurrentDesignation.Location = player.VoxSelector.VoxelUnderMouse;

                World.ShowTooltip("Click to build. Press R/T to rotate.");
                CurrentCraftBody.SetTintRecursive(IsValid(CurrentDesignation) ? Color.Green : Color.Red);
            }
        }