Beispiel #1
0
    internal void LoadBlock(MapBlock block)
    {
        if (block.items.Count > 0)
        {
            loadedAnyItems = true;
        }
        foreach (var item in block.items)
        {
            removedItems.Remove(item.id);
            ItemModel placedItem;
            if (!sceneItems.ContainsKey(item.id))
            {
                if (itemCount.ContainsKey(item.pos) && itemCount[item.pos] >= GameSettings.Instance.rendering.maxItemsPerTile)
                {
                    continue;
                }

                placedItem          = InstantiateItem(item, transform);
                sceneItems[item.id] = placedItem;
            }
            else
            {
                placedItem = sceneItems[item.id];
            }

            if (itemCount.ContainsKey(item.pos) && itemCount[item.pos] >= GameSettings.Instance.rendering.maxItemsPerTile)
            {
                placedItem.gameObject.SetActive(false);
                continue;
            }
            int currentTileCount = 0;
            if (itemCount.ContainsKey(item.pos))
            {
                currentTileCount = itemCount[item.pos];
            }
            itemCount[item.pos] = currentTileCount + 1;
            //RaycastHit hitInfo;
            //Vector3 position = GameMap.DFtoUnityCoord(item.pos) + Stacker.SpiralHemisphere(currentTileCount);
            //if (Physics.Raycast(position + new Vector3(0, 2.9f, 0), Vector3.down, out hitInfo, 3, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Collide))
            //    placedItem.transform.position = hitInfo.point;
            //else
            placedItem.transform.position = GameMap.DFtoUnityCoord(item.pos.x + item.subpos_x, item.pos.y + item.subpos_y, item.pos.z + item.subpos_z);
            if (item.projectile)
            {
                placedItem.transform.position += new Vector3(0, GameMap.tileHeight / 2, 0);
                if (item.velocity_x > 0 || item.velocity_y > 0 || item.velocity_z > 0)
                {
                    placedItem.transform.rotation = Quaternion.LookRotation(GameMap.DFtoUnityDirection(item.velocity_x, item.velocity_y, item.velocity_z), Vector3.up);
                }
            }
            else
            {
                placedItem.transform.position += (Stacker.SpiralHemisphere(currentTileCount) + new Vector3(0, GameMap.floorHeight, 0));
                if (item.velocity_x > 0 || item.velocity_y > 0 || item.velocity_z > 0)
                {
                    placedItem.transform.rotation = Quaternion.LookRotation(GameMap.DFtoUnityDirection(item.velocity_x, item.velocity_y, item.velocity_z), Vector3.up);
                }
            }
        }
    }
        private bool temp_HasContainer; //Replace with the limit switch output

        #endregion Fields

        #region Constructors

        public AutomatedRobot()
        {
            stacker = new Stacker();
            drive = new SmartDrive();
            driveWait = 0;

            state = RobotStates.Stack; //Assuming we start with can by our corner.
        }
Beispiel #3
0
        //Elevator elevator;
        //ToteChute toteChute;
        //Arm arm;
        /**
         * This function is run when the robot is first started up and should be
         * used for any initialization code.
         */
        public override void RobotInit()
        {
            AutonDriveWait = new SWave_WaitByCallCount(75);

            joysticks = new Joysticks();
            drive = new SmartDrive();
            stacker = new Stacker();
            canburglar = new CanBurglar();
            compressor = new Compressor();

            compressor.Start();
        }
Beispiel #4
0
        public void TestPopEmptyStack()
        {
            Stacker s = new Stacker();

            Assert.Null(s.Pop());
        }
Beispiel #5
0
 /// <summary>
 /// Gets the stack.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <returns></returns>
 public StackedValue GetStack(ChartPoint point)
 {
     return(Stacker.GetStack(point, Position));
 }
Beispiel #6
0
 /// <summary>
 /// Stacks the point.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <returns></returns>
 public double StackPoint(ChartPoint point)
 {
     return(Stacker.StackPoint(point, Position));
 }
Beispiel #7
0
    void UpdateItem(Item item)
    {
        ItemModel placedItem;
        var       itemPos = GameMap.DFtoUnityCoord(item.pos.x + item.subpos_x, item.pos.y + item.subpos_y, item.pos.z + item.subpos_z);

        //Disable the item if it's too far from the camera.
        if ((itemPos - Camera.main.transform.position).sqrMagnitude > (GameSettings.Instance.rendering.itemDrawDistance * GameSettings.Instance.rendering.itemDrawDistance))
        {
            if (sceneItems.ContainsKey(item.id))
            {
                sceneItems[item.id].gameObject.SetActive(false);
            }
            return;
        }

        //Also disable if it's outside of the viewing AABB
        if (!((item.pos.z < (GameMap.Instance.firstPerson ? GameMap.Instance.PosZ + GameSettings.Instance.rendering.drawRangeUp : GameMap.Instance.PosZ)) &&
              (item.pos.z >= (GameMap.Instance.PosZ - GameSettings.Instance.rendering.drawRangeDown)) &&
              (item.pos.x / GameMap.blockSize > (GameMap.Instance.PosXBlock - GameSettings.Instance.rendering.drawRangeSide)) &&
              (item.pos.x / GameMap.blockSize < (GameMap.Instance.PosXBlock + GameSettings.Instance.rendering.drawRangeSide)) &&
              (item.pos.y / GameMap.blockSize > (GameMap.Instance.PosYBlock - GameSettings.Instance.rendering.drawRangeSide)) &&
              (item.pos.y / GameMap.blockSize < (GameMap.Instance.PosYBlock + GameSettings.Instance.rendering.drawRangeSide))))
        {
            if (sceneItems.ContainsKey(item.id))
            {
                sceneItems[item.id].gameObject.SetActive(false);
            }
            return;
        }

        //Limit the number of items per tile.
        if (itemCount.ContainsKey(item.pos) && itemCount[item.pos] >= GameSettings.Instance.rendering.maxItemsPerTile)
        {
            if (sceneItems.ContainsKey(item.id))
            {
                sceneItems[item.id].gameObject.SetActive(false);
            }
            return;
        }

        //Instantiate it if it's not already there.
        if (!sceneItems.ContainsKey(item.id))
        {
            placedItem          = InstantiateItem(item, transform);
            sceneItems[item.id] = placedItem;
        }
        else
        {
            placedItem = sceneItems[item.id];
            placedItem.gameObject.SetActive(true);

            //If there's no significant differences between the new item and the existing one, there's no need to update it.
            if (AreItemsEqual(placedItem.originalItem, item))
            {
                return;
            }
            else
            {
                placedItem.originalItem = item;
            }
        }

        int currentTileCount = 0;

        if (itemCount.ContainsKey(item.pos))
        {
            currentTileCount = itemCount[item.pos];
        }
        itemCount[item.pos] = currentTileCount + 1;
        //RaycastHit hitInfo;
        //Vector3 position = GameMap.DFtoUnityCoord(item.pos) + Stacker.SpiralHemisphere(currentTileCount);
        //if (Physics.Raycast(position + new Vector3(0, 2.9f, 0), Vector3.down, out hitInfo, 3, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Collide))
        //    placedItem.transform.position = hitInfo.point;
        //else
        placedItem.transform.position = itemPos;
        if (item.projectile)
        {
            placedItem.transform.position += new Vector3(0, GameMap.tileHeight / 2, 0);
            if (item.velocity_x > 0 || item.velocity_y > 0 || item.velocity_z > 0)
            {
                placedItem.transform.rotation = Quaternion.LookRotation(GameMap.DFtoUnityDirection(item.velocity_x, item.velocity_y, item.velocity_z), Vector3.up);
            }
        }
        else
        {
            placedItem.transform.position += (Stacker.SpiralHemisphere(currentTileCount) + new Vector3(0, GameMap.floorHeight, 0));
            if (item.velocity_x > 0 || item.velocity_y > 0 || item.velocity_z > 0)
            {
                placedItem.transform.rotation = Quaternion.LookRotation(GameMap.DFtoUnityDirection(item.velocity_x, item.velocity_y, item.velocity_z), Vector3.up);
            }
        }
    }
Beispiel #8
0
 /// <summary>
 /// Stacks the point.
 /// </summary>
 /// <param name="point">The point.</param>
 /// <returns></returns>
 public float StackPoint(ChartPoint point)
 {
     return(Stacker.StackPoint(point, Position));
 }
Beispiel #9
0
        private void Initialize()
        {
            algo                       = new Algorithm(2, new Size(8, 8), 9);
            algo.Rearrange            += Algo_Rearrange;
            algo.DepartureTimeReached += Algo_DepartureTimeReached;
            objects.Add(algo);

            station             = new StorageStation(1.0, Color.Transparent, 490, 10);
            station.BorderStyle = BorderStyle.FixedSingle;
            station.Name        = "station";
            station.ZIndex      = 0;
            station.CanCollect += Station_CanCollect;
            Controls.Add(station);
            objects.Add(station);

            shelf1                  = new Shelf(150, 90, 1, Color.Black);
            shelf1.ZIndex           = 0;
            shelf1.Name             = "shelf1";
            shelf1.BaggageDequeued += Shelf1_BaggageDequeued;
            Controls.Add(shelf1);
            objects.Add(shelf1);

            shelf2                  = new Shelf(520, 90, 1, Color.Black);
            shelf2.ZIndex           = 0;
            shelf2.Name             = "shelf2";
            shelf2.BaggageDequeued += Shelf2_BaggageDequeued;
            Controls.Add(shelf2);
            objects.Add(shelf2);

            inputStackerLeft = new Stacker(1.0, Color.Ivory);
            inputStackerLeft.OriginalLocation    = inputStackerLeft.Location = new Point(shelf1.Location.X + shelf1.Size.Width - inputStackerLeft.Size.Width, shelf1.Top - inputStackerLeft.Size.Height - 10);
            inputStackerLeft.BorderStyle         = BorderStyle.FixedSingle;
            inputStackerLeft.ZIndex              = 2;
            inputStackerLeft.Speed               = Speed;
            inputStackerLeft.Name                = "inputStackerLeft";
            inputStackerLeft.TargetPointReached += InputStackerLeft_TargetPointReached;
            Controls.Add(inputStackerLeft);
            objects.Add(inputStackerLeft);

            inputStackerRight = new Stacker(1.0, Color.Ivory);
            inputStackerRight.OriginalLocation    = inputStackerRight.Location = new Point(shelf2.Location.X, shelf2.Top - inputStackerRight.Size.Height - 10);
            inputStackerRight.BorderStyle         = BorderStyle.FixedSingle;
            inputStackerRight.ZIndex              = 2;
            inputStackerRight.Speed               = Speed;
            inputStackerRight.Name                = "inputStackerRight";
            inputStackerRight.TargetPointReached += InputStackerRight_TargetPointReached;
            Controls.Add(inputStackerRight);
            objects.Add(inputStackerRight);

            outputStackerLeft = new Stacker(1.0, Color.HotPink);
            outputStackerLeft.OriginalLocation      = outputStackerLeft.Location = new Point(shelf1.Location.X + shelf1.Size.Width - outputStackerLeft.Size.Width, shelf1.Top + shelf1.Size.Height + 10);
            outputStackerLeft.BorderStyle           = BorderStyle.FixedSingle;
            outputStackerLeft.ZIndex                = 2;
            outputStackerLeft.Speed                 = Speed;
            outputStackerLeft.Name                  = "outputStackerLeft";
            outputStackerLeft.TargetPointReached   += OutputStackerLeft_TargetPointReached;
            outputStackerLeft.OriginalPointReached += OutputStackerLeft_OriginalPointReached;
            Controls.Add(outputStackerLeft);
            objects.Add(outputStackerLeft);

            outputStackerRight = new Stacker(1.0, Color.HotPink);
            outputStackerRight.OriginalLocation      = outputStackerRight.Location = new Point(shelf2.Location.X, shelf2.Top + shelf2.Size.Height + 10);
            outputStackerRight.BorderStyle           = BorderStyle.FixedSingle;
            outputStackerRight.ZIndex                = 2;
            outputStackerRight.Speed                 = Speed;
            outputStackerRight.Name                  = "outputStackerRight";
            outputStackerRight.TargetPointReached   += OutputStackerRight_TargetPointReached;
            outputStackerRight.OriginalPointReached += OutputStackerRight_OriginalPointReached;
            Controls.Add(outputStackerRight);
            objects.Add(outputStackerRight);

            middleStacker = new Stacker(1.0, Color.Green);
            middleStacker.OriginalLocation    = middleStacker.Location = new Point(outputStackerLeft.Location.X + outputStackerLeft.Size.Width + 10, outputStackerLeft.Location.Y);
            middleStacker.BorderStyle         = BorderStyle.None;
            middleStacker.ZIndex              = 2;
            middleStacker.Speed               = Speed;
            middleStacker.Name                = "middleStacker";
            middleStacker.TargetPointReached += MiddleStacker_TargetPointReached;
            Controls.Add(middleStacker);
            objects.Add(middleStacker);

            leftConveyor                 = new Conveyor(1.0, Color.Ivory, outputStackerLeft.Location.X + 3, outputStackerLeft.Location.Y + outputStackerLeft.Size.Height + 10);
            leftConveyor.ZIndex          = 2;
            leftConveyor.Name            = "leftConveyor";
            leftConveyor.FlightChanged  += LeftConveyor_FlightChanged;
            leftConveyor.CollectBaggage += LeftConveyor_CollectBaggage;
            Controls.Add(leftConveyor);
            objects.Add(leftConveyor);

            rightConveyor                 = new Conveyor(1.0, Color.Ivory, outputStackerRight.Location.X + 3, outputStackerRight.Location.Y + outputStackerRight.Size.Height + 10);
            rightConveyor.ZIndex          = 2;
            rightConveyor.Name            = "leftConveyor";
            rightConveyor.FlightChanged  += RightConveyor_FlightChanged;
            rightConveyor.CollectBaggage += RightConveyor_CollectBaggage;
            Controls.Add(rightConveyor);
            objects.Add(rightConveyor);

            config = new XmlHelper("config.xml");
            LoadConfig();

            baggageAdder = new BaggageAdder(algo.FlightBaggageCount, station);

            SetDisplayOrder();
        }
Beispiel #10
0
        /// <summary>
        /// Processes the list of ingredient game objects / boolean selections and creates a new
        /// array of IngredientScreenInfo data that is used for displaying those ingredients in our
        /// custom menu.
        /// </summary>
        public static List <IngredientScreenInfo> GetIngredientScreenInfo(List <GameObject> ingredients, List <bool> selections)
        {
            Dictionary <string, int>    liquidAmountsOnHand = null;
            List <IngredientScreenInfo> ingredientInfo      = new List <IngredientScreenInfo>();
            GetShortDescriptionEvent    descriptionEvent    = new GetShortDescriptionEvent();
            int index = 0;

            foreach (GameObject ing in ingredients)
            {
                IngredientScreenInfo      info    = new IngredientScreenInfo(selections, index);
                PreparedCookingIngredient ingPart = ing?.GetPart <PreparedCookingIngredient>();
                LiquidVolume liquid            = ing?.LiquidVolume;
                string       liquidDescription = string.Empty;

                //simple ingredient name
                if (ingPart != null)
                {
                    info.OptionName = ing.ShortDisplayName;
                }
                else if (liquid != null)
                {
                    liquidDescription = liquid.GetLiquidDescription(false);
                    info.OptionName   = ing.ShortDisplayName + " " + liquidDescription;
                }
                else
                {
                    LogUnique("(Error) Unable to process ingredient description for ingredient "
                              + $"'{ing?.DisplayNameStripped} for display on IngredientSelectionScreen.");
                }

                //cook effect description
                string cookEffect = string.Empty;
                descriptionEvent.Postfix.Clear();
                if (ingPart != null)
                {
                    ingPart.HandleEvent(descriptionEvent);
                    cookEffect = descriptionEvent.Postfix.ToString();
                }
                else if (liquid != null)
                {
                    liquid.HandleEvent(descriptionEvent);
                    cookEffect = descriptionEvent.Postfix.ToString();
                }
                info.CookEffect = SimplifyCookEffectDescription(cookEffect, ing);

                //number of ingredient uses remaining
                int    amount = 0;
                string unit   = string.Empty;
                info.UseCount = string.Empty;
                if (ingPart != null)
                {
                    Stacker stackInfo = ing.GetPart <Stacker>();
                    amount = stackInfo != null ? stackInfo.Number : ingPart.charges;
                    unit   = "serving";
                }
                else if (liquid != null)
                {
                    //Get the player's total volume of this type of liquid in all containers.
                    //In the base game, the ingredient selector only shows the volume of the first
                    //container found - it ignores additional drams in extra containers.
                    if (liquidAmountsOnHand == null)
                    {
                        liquidAmountsOnHand = GetLiquidAmountsOnHand();
                    }
                    if (liquidAmountsOnHand.ContainsKey(liquidDescription))
                    {
                        amount = liquidAmountsOnHand[liquidDescription];
                    }
                    else
                    {
                        amount = liquid.Volume;
                    }
                    unit = "dram";
                }
                if (amount == 1)
                {
                    info.UseCount = "{{y|  }}{{C|1}}{{y| " + unit + "}}";
                }
                else if (amount > 1 && amount <= 9)
                {
                    info.UseCount = "{{y|  }}{{C|" + amount.ToString() + "}}{{y| " + unit + "s}}";
                }
                else if (amount > 1 && amount <= 99)
                {
                    info.UseCount = "{{y| }}{{C|" + amount.ToString() + "}}{{y| " + unit + "s}}";
                }
                else if (amount >= 100)
                {
                    info.UseCount = "{{C|" + amount.ToString() + "}}{{y| " + unit + "s}}";
                }

                ingredientInfo.Add(info);
                index++;
            }
            return(ingredientInfo);
        }