Example #1
0
 // Use this for initialization
 void Start()
 {
     bSys               = GetComponent <BlockSystem>();
     blockData          = GetComponent <BlockData>();
     blockSelectCounter = 0;
     loadBlocks();
 }
Example #2
0
    private void Awake()
    {
        blockSys = GetComponent <BlockSystem>();
        buildSys = GetComponent <BuildSystem>();

        ToggleInv(false);
    }
Example #3
0
 public void Initialize(BlockSystem localBlockSystem, Int3 localLocation)
 {
     LocalBlockSystem   = localBlockSystem;
     LocalLocation      = localLocation;
     name               = $"{LocalBlockSystem.gameObject.name}: {name} {LocalLocation.x} {LocalLocation.y} {LocalLocation.z}";
     transform.parent   = LocalBlockSystem.transform;
     transform.position = LocalBlockSystem.GetBlockWorldPositionByLocation(LocalLocation);
 }
Example #4
0
        private void Search()
        {
            BlockFilter <IMyTextPanel> block_filter = BlockFilter <IMyTextPanel> .Create(Me, MyProperty.lcd_filter);

            lcds = BlockSystem <IMyTextPanel> .SearchByFilter(this, block_filter);

            search = false;
        }
Example #5
0
 private void Start()
 {
     instance          = this;
     peerToPeerManager = multiplayerWorlds.GetComponent <PeerToPeerManager>();
     blockSystem       = GetComponent <BlockSystem>();
     playerMove        = player.GetComponent <PlayerMove>();
     Debug.Log("Building System Initialized!");
 }
Example #6
0
            private void Search()
            {
                BlockFilter <IMyProductionBlock> block_filter = BlockFilter <IMyProductionBlock> .Create(DisplayLcd.lcd, filter);

                producers = BlockSystem <IMyProductionBlock> .SearchByFilter(DisplayLcd.program, block_filter);

                search = false;
            }
Example #7
0
            private void Search()
            {
                BlockFilter <IMyShipDrill> block_filter = BlockFilter <IMyShipDrill> .Create(DisplayLcd.lcd, filter);

                drill_inventories = BlockSystem <IMyShipDrill> .SearchByFilter(DisplayLcd.program, block_filter);

                search = false;
            }
Example #8
0
    private void Awake()
    {
        //store reference to block system script
        blockSys = GetComponent <BlockSystem>();

        //find player and store reference
        playerObject = GameObject.Find("Player");
    }
Example #9
0
            private void Search()
            {
                BlockFilter <IMyTerminalBlock> block_filter = BlockFilter <IMyTerminalBlock> .Create(DisplayLcd.lcd, filter);

                block_filter.HasInventory = true;
                inventories = BlockSystem <IMyTerminalBlock> .SearchByFilter(DisplayLcd.program, block_filter);

                search = false;
            }
Example #10
0
        private void Search()
        {
            BlockFilter <IMyDoor> block_filter1 = BlockFilter <IMyDoor> .Create(Me, "*");

            doors = BlockSystem <IMyDoor> .SearchByFilter(this, block_filter1);

            BlockFilter <IMySensorBlock> block_filter2 = BlockFilter <IMySensorBlock> .Create(Me, "*");

            sensors = BlockSystem <IMySensorBlock> .SearchByFilter(this, block_filter2);
        }
Example #11
0
        private void Init()
        {
            MyProperty = new KProperty(this);
            MyProperty.Load();
            Stage          = 0;
            bottom_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Bottom Pistons");

            bottom_pistons.ForEach(delegate(IMyPistonBase block) {
                block.MinLimit = MyProperty.locker_position_min;
                block.MaxLimit = MyProperty.locker_position_max;
            });
            bottom_mergers = BlockSystem <IMyShipMergeBlock> .SearchByGroup(this, "Foreuse Bottom Mergers");

            top_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Top Pistons");

            top_pistons.ForEach(delegate(IMyPistonBase block) {
                block.MinLimit = MyProperty.locker_position_min;
                block.MaxLimit = MyProperty.locker_position_max;
            });
            top_mergers = BlockSystem <IMyShipMergeBlock> .SearchByGroup(this, "Foreuse Top Mergers");

            connector = BlockSystem <IMyShipConnector> .SearchByName(this, "Foreuse Connector Drills");

            levage_pistons = BlockSystem <IMyPistonBase> .SearchByGroup(this, "Foreuse Levage Pistons");

            levage_pistons.ForEach(delegate(IMyPistonBase block) {
                block.MinLimit = MyProperty.elevator_position_min;
                block.MaxLimit = MyProperty.elevator_position_max;
            });

            grinder_stator = BlockSystem <IMyMotorStator> .SearchByName(this, "Foreuse Grinder Stator");

            grinders = BlockSystem <IMyShipGrinder> .SearchByGroup(this, "Foreuse Grinders");

            welder_stator = BlockSystem <IMyMotorStator> .SearchByName(this, "Foreuse Welder Stator");

            welders = BlockSystem <IMyShipWelder> .SearchByGroup(this, "Foreuse Welders");

            projector = BlockSystem <IMyProjector> .SearchByName(this, "Foreuse Projector Drill");

            light = BlockSystem <IMyLightingBlock> .SearchByGroup(this, "Foreuse Rotating Light");

            drills = BlockSystem <IMyShipDrill> .SearchByGroup(this, "Foreuse Drills");

            control_lcds = BlockSystem <IMyTextPanel> .SearchByName(this, "Foreuse Control LCD");

            control_lcds.ForEach(delegate(IMyTextPanel block)
            {
                block.ContentType = ContentType.TEXT_AND_IMAGE;
            });

            SequenceBlocks = new List <int>()
            {
            };
        }
Example #12
0
        private void UnRenamePrefix(string tag)
        {
            BlockSystem <IMyTerminalBlock> blocks = BlockSystem <IMyTerminalBlock> .SearchBlocks(this);

            blocks.ForEach(delegate(IMyTerminalBlock block)
            {
                if (block.CustomName.StartsWith(tag))
                {
                    block.CustomName = block.CustomName.Replace(tag + " ", "");
                }
            });
        }
Example #13
0
        private void Prepare()
        {
            stators = BlockSystem <IMyMotorStator> .SearchByTag(this, MyProperty.Search_Rotor);

            pistonUp = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Up);

            pistonDown = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Down);

            pistonRayon = BlockSystem <IMyPistonBase> .SearchByTag(this, MyProperty.Search_Piston_Rayon);

            drills = BlockSystem <IMyShipDrill> .SearchBlocks(this);

            SetTargetValues();
        }
Example #14
0
        private void Display()
        {
            WriteText($"Machine Mode:{Mode}", false);
            WriteText($"Machine Cycle:{Cycle}", true);
            if (Sequence != null && Sequence.Count > Stage)
            {
                WriteText($"Machine Action:{Sequence[Stage]}", true);
            }
            WriteText($"Machine Stage:{Stage}", true);
            BlockSystem <IMyShipConnector> connectors = BlockSystem <IMyShipConnector> .SearchBlocks(this);

            float deep = MyProperty.elevator_position_max * connectors.List.Count;

            WriteText($"Machine Deep:{deep}", true);
        }
Example #15
0
        private void Search()
        {
            BlockFilter <IMyBlockGroup> group_filter = BlockFilter <IMyBlockGroup> .Create(Me, MyProperty.filter);

            Groups = BlockSystem <IMyBlockGroup> .SearchGroupFilter(this, group_filter);

            Airlocks = new List <Airlock>();
            if (Groups != null)
            {
                Groups.ForEach(delegate(IMyBlockGroup group)
                {
                    Airlocks.Add(new Airlock(this, group.Name));
                });
            }
        }
Example #16
0
 private void Start()
 {
     bSys               = GetComponent <BlockSystem>();
     blockData          = GetComponent <BlockData>();
     blockSelectCounter = 0;
     buildModeOn        = true;
     destroyModeOn      = false;
     email              = username_static.email;
     mazeTitle          = username_static.mazeTitle;
     userId             = username_static.userId;
     database           = GetComponent <DatabaseScript>();
     if (!username_static.newMaze)
     {
         loadBlocks();
     }
 }
 public override Block[,,] GenerateBlocks(BlockSystem localBlockSystem)
 {
     Block[,,] blocks = new Block[Size, Size, Size];
     for (int x = 0; x < Size; x++)
     {
         for (int y = 0; y < Size; y++)
         {
             for (int z = 0; z < Size; z++)
             {
                 Block block = Instantiate(BlockPrefab).GetComponent <Block>();
                 block.Initialize(localBlockSystem, new Int3(x, y, z));
                 blocks[x, y, z] = block;
             }
         }
     }
     return(blocks);
 }
Example #18
0
            private void Search()
            {
                cockpit = BlockSystem <IMyCockpit> .SearchBlocks(DisplayLcd.program);

                thrusts_up = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Up");

                thrusts_down = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Down");

                thrusts_left = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Left");

                thrusts_right = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Right");

                thrusts_forward = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Forward");

                thrusts_backward = BlockSystem <IMyThrust> .SearchByGroup(DisplayLcd.program, "Thrusters Backward");

                search = false;
            }
Example #19
0
        private void Prepare()
        {
            BlockFilter <IMyRefinery> filterRefinery = new BlockFilter <IMyRefinery>()
            {
                CubeGrid = Me.CubeGrid
            };

            refinery = BlockSystem <IMyRefinery> .SearchByFilter(this, filterRefinery);

            refinery.ForEach(delegate(IMyRefinery block)
            {
                block.UseConveyorSystem = false;
            });
            BlockFilter <IMyCargoContainer> filterContainer = new BlockFilter <IMyCargoContainer>()
            {
                Filter   = "Ore",
                CubeGrid = Me.CubeGrid
            };

            stock = BlockSystem <IMyCargoContainer> .SearchByFilter(this, filterContainer);
        }
Example #20
0
        void RunContinuousLogic()
        {
            if (search)
            {
                Search();
            }
            WriteText($"LCD found: {(lcds != null ? lcds.List.Count : 0)}", false);
            BlockFilter <IMyThrust> block_filter = BlockFilter <IMyThrust> .Create(Me, "C:Up");

            BlockSystem <IMyThrust> thrust = BlockSystem <IMyThrust> .SearchByFilter(this, block_filter);

            if (!thrust.IsEmpty)
            {
                ParserInfo parser = new ParserInfo(this);
                IMyThrust  block  = thrust.First;
                parser.ParserTitle(block);
                parser.ParserTerminalBlock(block);
                parser.ParserThrust(block);
                parser.ParserCubeBlock(block);
            }
        }
Example #21
0
        public Program()
        {
            MyProperty = new KProperty(this);
            MyProperty.Load();
            drawingSurface             = Me.GetSurface(0);
            drawingSurface.ContentType = ContentType.TEXT_AND_IMAGE;
            Runtime.UpdateFrequency    = UpdateFrequency.Update100;

            lat_stators = BlockSystem <IMyMotorStator> .SearchByName(this, MyProperty.Name);

            if (!lat_stators.IsEmpty)
            {
                lon_stators = BlockSystem <IMyMotorStator> .SearchByGrid(this, lat_stators.First.Top.CubeGrid);

                solar_panels = new BlockSystem <IMySolarPanel>();
                foreach (IMyMotorStator lon_stator in lon_stators.List)
                {
                    solar_panels.Merge(BlockSystem <IMySolarPanel> .SearchByGrid(this, lon_stator.Top.CubeGrid));
                }
            }
        }
Example #22
0
            public void Search()
            {
                BlockFilter <IMyDoor> block_filter_doors = BlockFilter <IMyDoor> .Create(program.Me, $"G:{GroupFilter}");

                doors = BlockSystem <IMyDoor> .SearchByFilter(program, block_filter_doors);

                BlockFilter <IMyAirVent> block_filter_airvent = BlockFilter <IMyAirVent> .Create(program.Me, $"G:{GroupFilter}");

                airvent = BlockSystem <IMyAirVent> .SearchByFilter(program, block_filter_airvent);

                BlockFilter <IMyTextPanel> block_filter_control = BlockFilter <IMyTextPanel> .Create(program.Me, $"G:{GroupFilter}");

                control_panel = BlockSystem <IMyTextPanel> .SearchByFilter(program, block_filter_control);

                BlockFilter <IMyLightingBlock> block_filter_light = BlockFilter <IMyLightingBlock> .Create(program.Me, $"G:{GroupFilter}");

                light = BlockSystem <IMyLightingBlock> .SearchByFilter(program, block_filter_light);

                BlockFilter <IMySoundBlock> block_filter_sound = BlockFilter <IMySoundBlock> .Create(program.Me, $"G:{GroupFilter}");

                sound = BlockSystem <IMySoundBlock> .SearchByFilter(program, block_filter_sound);

                if (control_panel != null)
                {
                    control_panel.ForEach(delegate(IMyTextPanel block)
                    {
                        block.ScriptBackgroundColor = Color.Black;
                    });
                }

                if (light != null)
                {
                    light.ForEach(delegate(IMyLightingBlock block)
                    {
                        block.Color = program.MyProperty.GetColor("Airlock", "running_color");
                    });
                    light.Off();
                }
            }
Example #23
0
    /* public static void BreakHighestBlockAtRangeFromLocation(Int3 origin, Int3 direction, int range)
     * {
     *  Int3 target = BlockSystemManager.Instance.AlignedSystem.GetLocationAtRange(origin, direction, range);
     *  Int3? highestSolidTarget = BlockSystemManager.Instance.AlignedSystem.GetHighestSolidLocation(target);
     *
     *  if (highestSolidTarget)
     *  {
     *      BlockSystemManager.Instance.AlignedSystem.Break((Int3)highestSolidTarget);
     *  }
     * } */

    public static void RandomlyDissolveTopLayer(BlockSystem blocks, float percentage, float duration)
    {
        List <Int3> toBreak = new List <Int3>();

        for (int x = 0; x < blocks.GetDimensions().x; x++)
        {
            for (int z = 0; z < blocks.GetDimensions().z; z++)
            {
                Int3?highest = blocks.GetHighestSolidLocation(x, z);
                if (Random.value > percentage && highest)
                {
                    toBreak.Add((Int3)highest);
                }
            }
        }

        foreach (Int3 block in toBreak)
        {
            CardEffectController.Instance.StartCoroutine(Coroutines.WaitThen(Random.value * duration, () =>
            {
                blocks.Break(block);
            }));
        }
    }
Example #24
0
            public Vector2 Draw(Drawing drawing, Vector2 position)
            {
                if (!enable)
                {
                    return(position);
                }
                List <string> types = new List <string>();

                if (tank_h2)
                {
                    types.Add("Hydrogen");
                }
                if (tank_o2)
                {
                    types.Add("Oxygen");
                }
                if (types.Count > 0)
                {
                    foreach (string type in types)
                    {
                        BlockSystem <IMyGasTank> tanks = BlockSystem <IMyGasTank> .SearchBlocks(DisplayLcd.program, block => block.BlockDefinition.SubtypeName.Contains(type));

                        float      volumes  = 0f;
                        float      capacity = 0f;
                        float      width    = 50f;
                        StyleGauge style    = new StyleGauge()
                        {
                            Orientation     = SpriteOrientation.Horizontal,
                            Fullscreen      = true,
                            Width           = width,
                            Height          = width,
                            Padding         = new StylePadding(0),
                            Round           = false,
                            RotationOrScale = 0.5f
                        };

                        MySprite text = new MySprite()
                        {
                            Type            = SpriteType.TEXT,
                            Color           = Color.DimGray,
                            Position        = position + new Vector2(0, 0),
                            RotationOrScale = 1f,
                            FontId          = drawing.Font,
                            Alignment       = TextAlignment.LEFT
                        };

                        tanks.ForEach(delegate(IMyGasTank block)
                        {
                            volumes  += (float)block.FilledRatio * block.Capacity;
                            capacity += block.Capacity;
                        });

                        drawing.DrawGauge(position, volumes, capacity, style);
                        position += new Vector2(0, 60);
                        switch (type)
                        {
                        case "Hydrogen":
                            text.Data = $"H2: {Math.Round(volumes, 2)}L / {Math.Round(capacity, 2)}L";
                            break;

                        case "Oxygen":
                            text.Data = $"O2: {Math.Round(volumes, 2)}L / {Math.Round(capacity, 2)}L";
                            break;
                        }
                        text.Position = position;
                        drawing.AddSprite(text);
                        position += new Vector2(0, 60);
                    }
                }
                return(position);
            }
Example #25
0
            private void Search()
            {
                BlockFilter <IMyThrust> block_thrusters_filter = BlockFilter <IMyThrust> .Create(program.Me, thrusters_filter);

                thrusters = BlockSystem <IMyThrust> .SearchByFilter(program, block_thrusters_filter);
            }
    public override Block[,,] GenerateBlocks(BlockSystem AlignedBlockSystem)
    {
        Transform smallerTransform = BlockSystemManager.Instance.PlayerSystem.GetDimensions().x < BlockSystemManager.Instance.EnemySystem.GetDimensions().x ? BlockSystemManager.Instance.PlayerSystem.transform : BlockSystemManager.Instance.EnemySystem.transform;

        // Positive vs negative is a bit more generic than left/right or up/down
        BlockSystem positiveSide            = null;
        BlockSystem negativeSide            = null;
        Int3        dimensions              = new Int3(0, 0, 0);
        Int3        positiveDimensions      = new Int3(0, 0, 0);
        Int3        negativeDimensions      = new Int3(0, 0, 0);
        int         positiveAlignmentOffset = 0;
        int         negativeAlignmentOffset = 0;

        switch (AlignmentEdge)
        {
        case Alignment.PlayerPositiveXToEnemyNegativeX:
            positiveSide = BlockSystemManager.Instance.PlayerSystem;
            negativeSide = BlockSystemManager.Instance.EnemySystem;

            positiveDimensions = positiveSide.GetDimensions();
            negativeDimensions = negativeSide.GetDimensions();

            dimensions = new Int3(positiveDimensions.x + negativeDimensions.x,
                                  Math.Max(positiveDimensions.y, negativeDimensions.y),
                                  Math.Max(positiveDimensions.z, negativeDimensions.z));

            if (positiveDimensions.z < negativeDimensions.z)
            {
                positiveAlignmentOffset = Mathf.FloorToInt(negativeDimensions.z / 2) - Mathf.FloorToInt(positiveDimensions.z / 2);
            }
            else if (positiveDimensions.z > negativeDimensions.z)
            {
                negativeAlignmentOffset = Mathf.FloorToInt(positiveDimensions.z / 2) - Mathf.FloorToInt(negativeDimensions.z / 2);
            }

            if (DrawDebugCubes)
            {
                smallerTransform.localPosition += new Vector3(-smallerTransform.GetComponent <BlockSystem>().GetDimensions().x, 0, 0);
                transform.localPosition        += new Vector3(-smallerTransform.GetComponent <BlockSystem>().GetDimensions().x, 0, 0);
            }
            break;

        case Alignment.PlayerPositiveZToEnemyNegativeZ:
            positiveSide = BlockSystemManager.Instance.PlayerSystem;
            negativeSide = BlockSystemManager.Instance.EnemySystem;

            positiveDimensions = positiveSide.GetDimensions();
            negativeDimensions = negativeSide.GetDimensions();

            dimensions = new Int3(Math.Max(positiveDimensions.x, negativeDimensions.x),
                                  Math.Max(positiveDimensions.y, negativeDimensions.y),
                                  positiveDimensions.z + negativeDimensions.z);

            if (positiveDimensions.x < negativeDimensions.x)
            {
                positiveAlignmentOffset = Mathf.FloorToInt(negativeDimensions.x / 2) - Mathf.FloorToInt(positiveDimensions.x / 2);
            }
            else if (positiveDimensions.x > negativeDimensions.x)
            {
                negativeAlignmentOffset = Mathf.FloorToInt(positiveDimensions.x / 2) - Mathf.FloorToInt(negativeDimensions.x / 2);
            }

            if (DrawDebugCubes)
            {
                smallerTransform.localPosition += new Vector3(0, 0, -smallerTransform.GetComponent <BlockSystem>().GetDimensions().z);
                transform.localPosition        += new Vector3(0, 0, -smallerTransform.GetComponent <BlockSystem>().GetDimensions().z);
            }
            break;

        case Alignment.EnemyPositiveXToPlayerNegativeX:
            positiveSide = BlockSystemManager.Instance.EnemySystem;
            negativeSide = BlockSystemManager.Instance.PlayerSystem;

            positiveDimensions = positiveSide.GetDimensions();
            negativeDimensions = negativeSide.GetDimensions();

            dimensions = new Int3(positiveDimensions.x + negativeDimensions.x,
                                  Math.Max(positiveDimensions.y, negativeDimensions.y),
                                  Math.Max(positiveDimensions.z, negativeDimensions.z));

            if (positiveDimensions.z < negativeDimensions.z)
            {
                positiveAlignmentOffset = Mathf.FloorToInt(negativeDimensions.z / 2) - Mathf.FloorToInt(positiveDimensions.z / 2);
            }
            else if (positiveDimensions.z > negativeDimensions.z)
            {
                negativeAlignmentOffset = Mathf.FloorToInt(positiveDimensions.z / 2) - Mathf.FloorToInt(negativeDimensions.z / 2);
            }

            if (DrawDebugCubes)
            {
                smallerTransform.localPosition += new Vector3(-smallerTransform.GetComponent <BlockSystem>().GetDimensions().x, 0, 0);
                transform.localPosition        += new Vector3(-smallerTransform.GetComponent <BlockSystem>().GetDimensions().x, 0, 0);
            }
            break;

        case Alignment.EnemyPositiveZToPlayerNegativeZ:
            positiveSide = BlockSystemManager.Instance.EnemySystem;
            negativeSide = BlockSystemManager.Instance.PlayerSystem;

            positiveDimensions = positiveSide.GetDimensions();
            negativeDimensions = negativeSide.GetDimensions();

            dimensions = new Int3(Math.Max(positiveDimensions.x, negativeDimensions.x),
                                  Math.Max(positiveDimensions.y, negativeDimensions.y),
                                  positiveDimensions.z + negativeDimensions.z);

            if (positiveDimensions.x < negativeDimensions.x)
            {
                positiveAlignmentOffset = Mathf.FloorToInt(negativeDimensions.x / 2) - Mathf.FloorToInt(positiveDimensions.x / 2);
            }
            else if (positiveDimensions.x > negativeDimensions.x)
            {
                negativeAlignmentOffset = Mathf.FloorToInt(positiveDimensions.x / 2) - Mathf.FloorToInt(negativeDimensions.x / 2);
            }


            if (DrawDebugCubes)
            {
                smallerTransform.localPosition += new Vector3(0, 0, -smallerTransform.GetComponent <BlockSystem>().GetDimensions().z);
                transform.localPosition        += new Vector3(0, 0, -smallerTransform.GetComponent <BlockSystem>().GetDimensions().z);
            }
            break;
        }


        Block[,,] blocks = new Block[dimensions.x, dimensions.y, dimensions.z];

        for (int x = 0; x < dimensions.x; x++)
        {
            for (int y = 0; y < dimensions.y; y++)
            {
                for (int z = 0; z < dimensions.z; z++)
                {
                    if (x < positiveDimensions.x && y < positiveDimensions.y && z < positiveDimensions.z)
                    {
                        if ((AlignmentEdge == Alignment.PlayerPositiveXToEnemyNegativeX || AlignmentEdge == Alignment.EnemyPositiveXToPlayerNegativeX) &&
                            z + positiveAlignmentOffset < dimensions.z)
                        {
                            blocks[x, y, z + positiveAlignmentOffset] = positiveSide.GetBlockByLocation(x, y, z);
                        }
                        else if ((AlignmentEdge == Alignment.PlayerPositiveZToEnemyNegativeZ || AlignmentEdge == Alignment.EnemyPositiveZToPlayerNegativeZ) &&
                                 x + positiveAlignmentOffset < dimensions.x)
                        {
                            blocks[x + positiveAlignmentOffset, y, z] = positiveSide.GetBlockByLocation(x, y, z);
                        }
                    }
                    else if (x >= positiveDimensions.x && y < negativeDimensions.y && z < negativeDimensions.z && (AlignmentEdge == Alignment.PlayerPositiveXToEnemyNegativeX || AlignmentEdge == Alignment.EnemyPositiveXToPlayerNegativeX))
                    {
                        if (z + negativeAlignmentOffset < dimensions.z)
                        {
                            blocks[x, y, z + negativeAlignmentOffset] = negativeSide.GetBlockByLocation(x - positiveDimensions.x, y, z);
                        }
                    }
                    else if (x < negativeDimensions.x && y < negativeDimensions.y && z >= positiveDimensions.z && (AlignmentEdge == Alignment.PlayerPositiveZToEnemyNegativeZ || AlignmentEdge == Alignment.EnemyPositiveZToPlayerNegativeZ))
                    {
                        if (x + negativeAlignmentOffset < dimensions.x)
                        {
                            blocks[x + negativeAlignmentOffset, y, z] = negativeSide.GetBlockByLocation(x, y, z - positiveDimensions.z);
                        }
                    }

                    if (blocks[x, y, z] != null)
                    {
                        blocks[x, y, z].AlignedLocation = new Int3(x, y, z);
                    }
                    else if (DrawDebugCubes)
                    {
                        Block block = Instantiate(DebugBlockPrefab).GetComponent <Block>();
                        block.Initialize(AlignedBlockSystem, new Int3(x, y, z));
                        block.AlignedLocation = new Int3(x, y, z);
                        blocks[x, y, z]       = block;
                    }
                }
            }
        }
        return(blocks);
    }
Example #27
0
    void Start()
    {
        instance = this;
        Debug.Log("Initializing inventory");
        buildingSystem = GameObject.FindGameObjectWithTag("BlockManager").GetComponent <BuildingSystem>();
        //Debug.Log("got BuildingSystem");
        blockSystem = GameObject.FindGameObjectWithTag("BlockManager").GetComponent <BlockSystem>();
        //Debug.Log("got BuildingSystem");
        numAvailableSlots = Math.Min(totalSlots, blockSystem.allBlocks.Count);

        //numAvailableQuickSlots = Math.Min(totalQuickSlots, numAvailableSlots);
        numAvailableQuickSlots = totalQuickSlots;

        numOfCategories = categories.transform.childCount;

        slots      = new Slot[numOfCategories, numAvailableSlots];
        quickSlots = new Slot[numAvailableQuickSlots];
        Debug.Log("All slots =  " + numAvailableSlots + " quick slots = " + numAvailableQuickSlots);


        for (int i = 0; i < numAvailableSlots; i++)
        {
            slots[activeCategory, i]             = slotHolder.transform.GetChild(i).GetComponent <Slot>();
            slots[activeCategory, i].isQuickSlot = false;
            if (i < blockSystem.allBlocks.Count)
            {
                slots[activeCategory, i].SetItem(blockSystem.allBlocks[i]);
            }
        }

        /*
         * for (int i = numAvailableSlots; i < totalSlots; i++)
         * {
         *  GameObject go = slotHolder.transform.GetChild(i).gameObject;
         *  go.SetActive(false);
         * }
         */
        Debug.Log("post slotHolder");
        for (int i = 0; i < numAvailableQuickSlots; i++)
        {
            quickSlots[i]             = quickInventory.transform.GetChild(i).GetComponent <Slot>();
            quickSlots[i].isQuickSlot = true;
            quickSlots[i].slotIndex   = i;
            if (i < blockSystem.allBlocks.Count)
            {
                quickSlots[i].SetItem(blockSystem.allBlocks[i]);
            }
        }

        /*
         * for (int i = numAvailableQuickSlots; i < totalQuickSlots; i++)
         * {
         *  GameObject go = quickInventory.transform.GetChild(i).gameObject;
         *  go.SetActive(false);
         * }
         */
        Debug.Log("post quickSlots");
        activeQuickSlot = quickSlots[0];
        Image anImage = activeQuickSlot.GetComponent <Image>();

        unselectedColor = anImage.color;
        anImage.color   = selectedColor;
        Debug.Log("Initialize Done");
    }
Example #28
0
 private void Start()
 {
     blockSystem = GetComponent <BlockSystem>();
 }
Example #29
0
 private void Start()
 {
     bSys = GetComponent <BlockSystem>();
     blockSelectCounter = 0;
 }
Example #30
0
            private void Search()
            {
                BlockFilter <IMyTextPanel> block_filter = BlockFilter <IMyTextPanel> .Create(program.Me, lcd_filter);

                lcds = BlockSystem <IMyTextPanel> .SearchByFilter(program, block_filter);
            }