private void MatchBoundarySizeToMapSize(EncounterLayerData encounterLayerData)
        {
            EncounterBoundaryChunkGameLogic encounterBoundaryChunk = encounterLayerData.GetComponentInChildren <EncounterBoundaryChunkGameLogic>();

            if (encounterBoundaryChunk != null)
            {
                Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToMedium] Setting Boundary Size to Maximum Map Size");
                List <RectHolder>          encounterBoundaryRectList         = new List <RectHolder>();
                EncounterObjectGameLogic[] childEncounterObjectGameLogicList = encounterBoundaryChunk.childEncounterObjectGameLogicList;

                float mapBorderSize = 50f;
                float mapSize       = 2048f;
                int   mapSide       = (int)(mapSize - mapBorderSize);

                for (int i = 0; i < childEncounterObjectGameLogicList.Length; i++)
                {
                    EncounterBoundaryRectGameLogic encounterBoundaryRectGameLogic = childEncounterObjectGameLogicList[i] as EncounterBoundaryRectGameLogic;

                    if (encounterBoundaryRectGameLogic != null)
                    {
                        encounterBoundaryRectGameLogic.width              = (int)mapSide;
                        encounterBoundaryRectGameLogic.height             = (int)mapSide;
                        encounterBoundaryRectGameLogic.transform.position = new Vector3(-25, encounterBoundaryRectGameLogic.transform.position.y, 25);
                        encounterLayerData.CalculateEncounterBoundary();
                    }
                    else
                    {
                        Main.Logger.Log($"[MaximiseBoundarySize] This encounter has no boundary to maximise.");
                    }
                }
            }
        }
        private void SetBoundarySizeToMedium(EncounterLayerData encounterLayerData, float size)
        {
            EncounterBoundaryChunkGameLogic encounterBoundaryChunk = encounterLayerData.GetComponentInChildren <EncounterBoundaryChunkGameLogic>();

            if (encounterBoundaryChunk != null)
            {
                Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToMedium] Increasing Boundary Size by '{size * 100}%'");
                List <RectHolder>          encounterBoundaryRectList         = new List <RectHolder>();
                EncounterObjectGameLogic[] childEncounterObjectGameLogicList = encounterBoundaryChunk.childEncounterObjectGameLogicList;

                float mapBorderSize = 50f;
                float mapSize       = 2048f;
                int   mapSide       = (int)(mapSize - mapBorderSize);

                for (int i = 0; i < childEncounterObjectGameLogicList.Length; i++)
                {
                    EncounterBoundaryRectGameLogic encounterBoundaryRectGameLogic = childEncounterObjectGameLogicList[i] as EncounterBoundaryRectGameLogic;

                    int mediumSize     = (int)(encounterBoundaryRectGameLogic.width * (1f + size));
                    int movementFactor = (int)(encounterBoundaryRectGameLogic.width * size);

                    int mediumXSize = mediumSize;
                    int mediumZSize = mediumSize;

                    if (mediumSize > mapSide)
                    {
                        Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToMedium] Medium size would be greater than map size. Using map size.'");
                        MatchBoundarySizeToMapSize(encounterLayerData);
                    }
                    else
                    {
                        if (encounterBoundaryRectGameLogic != null)
                        {
                            Vector3 position = encounterBoundaryRectGameLogic.transform.position;

                            Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToMedium] Boundary [X,Z] is [{position.x}, {position.z}]");

                            float xPosition = position.x - movementFactor;
                            float zPosition = position.z + movementFactor;

                            encounterBoundaryRectGameLogic.width  = (int)mediumSize;
                            encounterBoundaryRectGameLogic.height = (int)mediumSize;

                            encounterBoundaryRectGameLogic.transform.position = new Vector3(xPosition, encounterBoundaryRectGameLogic.transform.position.y, zPosition);
                            encounterLayerData.CalculateEncounterBoundary();
                        }
                        else
                        {
                            Main.Logger.Log($"[MaximiseBoundarySize] This encounter has no boundary to maximise.");
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void SetBoundarySizeToCustom(EncounterLayerData encounterLayerData, float size)
        {
            EncounterBoundaryChunkGameLogic encounterBoundaryChunk = encounterLayerData.GetComponentInChildren <EncounterBoundaryChunkGameLogic>();

            if (encounterBoundaryChunk != null)
            {
                Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToCustom] Increasing Boundary Size by '{size * 100}%'");
                List <RectHolder>          encounterBoundaryRectList         = new List <RectHolder>();
                EncounterObjectGameLogic[] childEncounterObjectGameLogicList = encounterBoundaryChunk.childEncounterObjectGameLogicList;

                float mapBorderSize = 50f;
                float mapSize       = 2048f;
                int   mapSide       = (int)(mapSize - mapBorderSize);

                for (int i = 0; i < childEncounterObjectGameLogicList.Length; i++)
                {
                    EncounterBoundaryRectGameLogic encounterBoundaryRectGameLogic = childEncounterObjectGameLogicList[i] as EncounterBoundaryRectGameLogic;

                    int xSizeFactor     = (int)(encounterBoundaryRectGameLogic.width * (1f + size));
                    int zSizeFactor     = (int)(encounterBoundaryRectGameLogic.height * (1f + size));
                    int xMovementFactor = (int)(encounterBoundaryRectGameLogic.width * size);
                    int zMovementFactor = (int)(encounterBoundaryRectGameLogic.height * size);

                    if (xSizeFactor > mapSide)
                    {
                        Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToCustom] Custom size would be greater than map size. Using map size.'");
                        MatchBoundarySizeToMapSize(encounterLayerData);
                    }
                    else
                    {
                        if (encounterBoundaryRectGameLogic != null)
                        {
                            Vector3 position = encounterBoundaryRectGameLogic.transform.position;

                            Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToCustom] Boundary [X,Z] originally was [{position.x}, {position.z}]");

                            float xPosition = 0;
                            if (position.x > 0)
                            {
                                xPosition = position.x - (xMovementFactor / 2f);
                                if (xPosition < 0)
                                {
                                    xPosition = 0;
                                }
                            }
                            else if (position.x < 0)
                            {
                                xPosition = position.x + (xMovementFactor / 2f);
                                if (xPosition > 0)
                                {
                                    xPosition = 0;
                                }
                            }

                            float zPosition = 0;
                            if (position.z > 0)
                            {
                                zPosition = position.z - (zMovementFactor / 2f);
                                if (zPosition < 0)
                                {
                                    zPosition = 0;
                                }
                            }
                            else if (position.z < 0)
                            {
                                zPosition = position.z + (zMovementFactor / 2f);
                                if (zPosition > 0)
                                {
                                    zPosition = 0;
                                }
                            }

                            encounterBoundaryRectGameLogic.width  = (int)xSizeFactor;
                            encounterBoundaryRectGameLogic.height = (int)zSizeFactor;

                            encounterBoundaryRectGameLogic.transform.position = new Vector3(xPosition, encounterBoundaryRectGameLogic.transform.position.y, zPosition);

                            Main.Logger.Log($"[MaximiseBoundarySize.SetBoundarySizeToCustom] Boundary [X,Z] is now [{xPosition}, {zPosition}]");

                            encounterLayerData.CalculateEncounterBoundary();
                        }
                        else
                        {
                            Main.Logger.Log($"[MaximiseBoundarySize] This encounter has no boundary to maximise.");
                        }
                    }
                }
            }
        }