public void MoveMap(Vector3 delta)
        {
            if (GameController.Singleton.IsMatchRunning)
            {
                foreach (var pool in wallSectionPools)
                {
                    foreach (var wallSection in pool.ActiveItems)
                    {
                        wallSection.transform.position -= delta;

                        if (wallSection.CanDespawn(-playerSeeRadius))
                        {
                            wallSection.Despawn();
                            pool.PoolItem(wallSection);
                        }
                    }
                }

                while (Mathf.FloorToInt(lastWallSectionSpawned.EndPoint.x) < playerSeeRadius)
                {
                    WallSection nextWallSection = GetWallSection(Random.value);
                    nextWallSection.Spawn(lastWallSectionSpawned.EndPoint);

                    lastWallSectionSpawned = nextWallSection;
                }

                foreach (var scorePoint in scorePointPool.ActiveItemsNonAloc)
                {
                    scorePoint.transform.position -= delta;
                }
            }
        }
 public bool CheckAgainstList(WallSection value, List <WallSection> toCheckAgainst)
 { // Checks to see if a value is in a list
     foreach (WallSection wallSection in toCheckAgainst)
     {
         if (value.side == wallSection.side)
         {
             return(true);
         }
     }
     return(false);
 }
        private void ResetAll()
        {
            foreach (var pair in wallSectionTemplatePairs)
            {
                pair.Value.PoolAllItems();

                foreach (var wallSection in pair.Value.PooledItemsNonAloc)
                {
                    wallSection.Despawn();
                }
            }

            lastWallSectionSpawned = null;
        }
Exemple #4
0
        public bool TryGetWall(WallSection section, out Wall wall)
        {
            foreach (Wall childWall in Walls)
            {
                if (childWall.Section == section)
                {
                    wall = childWall;
                    return(true);
                }
            }

            wall = null;
            return(false);
        }
Exemple #5
0
        public Wall(int index, Side side, WallSection section)
        {
            Index          = index;
            Side           = side;
            Section        = section;
            TextureName    = GetTextureNameFrom(side, section);
            Texture        = TextureManager.Texture(TextureName);
            meshComponents = new WallMeshComponents(this, Texture);

            (SectorPlane floor, SectorPlane ceiling) = FindBoundingPlane();
            FloorHeight   = floor.Height;
            CeilingHeight = ceiling.Height;

            AttachToSectorPlanes();
            side.Walls.Add(this);
        }
Exemple #6
0
    // Gets the node in the middle of a side
    public ComponentNode GetMiddleNode(WallSection wallSection)
    {
        ComponentSubGrid grid = parentWalls.GetComponent <ComponentGrid>().GetSubGrid(subGridIndex);

        foreach (ComponentWall wall in wallSection.walls)
        {
            ComponentNode parentNode = wall.parentNode;
            switch (wallSection.side)
            {
            case "Top":
                if (parentNode.gridX == grid.gridSizeX - 1 && parentNode.gridY == grid.gridSizeY / 2)
                {
                    return(parentNode);
                }
                break;

            case "Right":
                if (parentNode.gridX == grid.gridSizeX / 2 && parentNode.gridY == 0)
                {
                    return(parentNode);
                }
                break;

            case "Left":
                if (parentNode.gridX == grid.gridSizeX / 2 && parentNode.gridY == grid.gridSizeY - 1)
                {
                    return(parentNode);
                }
                break;

            case "Bottom":
                if (parentNode.gridX == 0 && parentNode.gridY == grid.gridSizeY / 2)
                {
                    return(parentNode);
                }
                break;
            }
        }
        return(new ComponentNode());
    }
Exemple #7
0
        private long FindResult(int currentLength, WallSection wallSection)
        {
            if(currentLength == length) {
                return 1;
            }

            String key = wallSection.GetKey() + currentLength;

            if (store.ContainsKey(key)) {
                return (long)store[key];
            }

            List<WallSection> children = wallSection.GetChildren();

            long result = 0;
            for (int i = 0; i < children.Count; i++) {
                result += FindResult(currentLength + 1, children[i]);
            }

            store.Add(key, result);
            return result;
        }
        private void BuildMap(float offset, SectionTemplate startSection)
        {
            // Start the current at half the length of the start section.
            Vector2 current = new Vector2(-20f + offset, 0f);

            WallSection wallSection = wallSectionTemplatePairs[startSection].GetItem();

            wallSection.Spawn(current);

            current = wallSection.EndPoint;

            lastWallSectionSpawned = wallSection;

            while (current.x < playerTransform.position.x + playerSeeRadius)
            {
                wallSection = wallSectionTemplatePairs[defaultSectionTemplate].GetItem();
                wallSection.Spawn(current);

                current = wallSection.EndPoint;

                lastWallSectionSpawned = wallSection;
            }
        }
Exemple #9
0
 public void AddChild(WallSection child)
 {
     children.Add(child);
 }
Exemple #10
0
            public static WallSection CreateWallSection(bool[] wall)
            {
                String key = "";

                for (int i = 0; i < wall.Length; i++) {
                    if (wall[i]) {
                        key += '1';
                    } else {
                        key += '0';
                    }
                }

                if (store.ContainsKey(key)) {
                    return (WallSection)store[key];
                } else {
                    WallSection newWallSection = new WallSection(wall, key);
                    store.Add(key, newWallSection);
                    list.Add(newWallSection);
                    return newWallSection;
                }
            }
Exemple #11
0
    public void CreateWalls(int subGridIndex_, int[,] intWallIDs, int[,] extWallIDs)
    {
        subGridIndex = subGridIndex_;
        if (db == null || dm == null)
        {
            dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>();
            db = GameObject.Find("Database").GetComponent <Database>();
        }
        if (wallsParent != null)
        {
            Destroy(wallsParent.gameObject); // Destroys all walls
        }
        WallSection previousTop    = topWall;
        WallSection previousRight  = rightWall;
        WallSection previousLeft   = leftWall;
        WallSection previousBottom = bottomWall;

        topWall           = new WallSection("Top", new List <ComponentWall>());
        topWall.reference = this;
        if (previousTop != null)
        {
            topWall.transparent = previousTop.transparent;
        }
        rightWall           = new WallSection("Right", new List <ComponentWall>());
        rightWall.reference = this;
        if (previousRight != null)
        {
            rightWall.transparent = previousRight.transparent;
        }
        leftWall           = new WallSection("Left", new List <ComponentWall>());
        leftWall.reference = this;
        if (previousLeft != null)
        {
            leftWall.transparent = previousLeft.transparent;
        }
        bottomWall           = new WallSection("Bottom", new List <ComponentWall>());
        bottomWall.reference = this;
        if (previousBottom != null)
        {
            bottomWall.transparent = previousBottom.transparent;
        }
        List <ComponentNode> edgeNodes = GetEdgeNodes();

        wallsParent = new GameObject("ComponentWalls");
        wallsParent.transform.parent = transform;
        ComponentSubGrid grid = parentWalls.GetComponent <ComponentGrid>().GetSubGrid(subGridIndex);

        foreach (ComponentNode node in edgeNodes)
        {
            int intWallID = -1;
            if (intWallIDs != null)
            {
                try
                {
                    intWallID = intWallIDs[node.gridX, node.gridY];
                    if (intWallID == 0)
                    {
                        intWallID = 12002;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    intWallID = 12002;
                }
            }
            else
            {
                intWallID = 12002;
            }

            int extWallID = -1;
            if (extWallIDs != null)
            {
                try
                {
                    extWallID = extWallIDs[node.gridX, node.gridY];
                    if (extWallID == 0)
                    {
                        extWallID = 12003;
                    }
                }
                catch (IndexOutOfRangeException)
                {
                    extWallID = 12003;
                }
            }
            else
            {
                extWallID = 12003;
            }

            // Right Row
            if (node.gridY == 0)
            {
                ComponentWall intComponentWall = CreateRightWall(grid, node, intWallID, true);
                ComponentWall extComponentWall = CreateRightWall(grid, node, extWallID, false);
                RaycastHit    hit;
                if (Physics.Raycast(intComponentWall.raycastObject.transform.position, Vector3.down, out hit)) // just do one walls raycast, because both walls are affected the same
                {
                    FloorTile np = hit.transform.gameObject.GetComponent <FloorTile>();
                    if (np != null)
                    {
                        if (np.node.componentEdge)
                        {
                            if (np.component != parentWalls.gameObject.name)
                            {
                                Destroy(extComponentWall.gameObject); // dont do an external wall if theres another component over there
                                if (parentWalls.showingTransparency)
                                {
                                    Destroy(intComponentWall.gameObject);                        // Destroy solid wall
                                    intComponentWall = CreateRightWall(grid, node, 12000, true); // Make a trans wall (it identifies as male)
                                }
                            }
                            else if (np.component == parentWalls.gameObject.name)
                            {
                                Destroy(intComponentWall.gameObject); // Destroy wall
                                Destroy(extComponentWall.gameObject); // Destroy wall
                            }
                        }
                    }
                    if (hit.transform.tag == "BuildableZone")
                    {
                        if (intComponentWall != null && extComponentWall != null)
                        {
                            GameObject newWallTrim = Instantiate(db.GetStoreObject(9999, 0).gameObject_);
                            newWallTrim.transform.parent = extComponentWall.transform;
                            //Vector3 pos = componentWall.transform.position;
                            //Vector3 trimPos = new Vector3(pos.x, .02f, pos.z);
                            //newWallTrim.transform.position = trimPos + new Vector3(0, 0, -0.05f);
                            //newWallTrim.transform.eulerAngles = componentWall.gameObject.transform.eulerAngles;
                            //newWallTrim.transform.localScale = new Vector3(1, 2, .1f);
                        }
                    }
                }
            }

            // Left Row
            if (node.gridY == grid.gridSizeY - 1)
            {
                ComponentWall intComponentWall = CreateLeftWall(grid, node, intWallID, true);
                ComponentWall extComponentWall = CreateLeftWall(grid, node, extWallID, false);
                RaycastHit    hit;
                if (Physics.Raycast(intComponentWall.raycastObject.transform.position, Vector3.down, out hit))
                {
                    FloorTile np = hit.transform.gameObject.GetComponent <FloorTile>();
                    if (np != null)
                    {
                        if (np.node.componentEdge)
                        {
                            if (np.component != parentWalls.gameObject.name)
                            {
                                Destroy(extComponentWall.gameObject); // dont do an external wall if theres another component over there
                                if (parentWalls.showingTransparency)
                                {
                                    Destroy(intComponentWall.gameObject);                       // Destroy solid wall
                                    intComponentWall = CreateLeftWall(grid, node, 12000, true); // Make a trans wall (it identifies as male)
                                }
                            }
                            else if (np.component == parentWalls.gameObject.name)
                            {
                                Destroy(intComponentWall.gameObject); // Destroy wall
                                Destroy(extComponentWall.gameObject); // Destroy wall
                            }
                        }
                    }
                    if (hit.transform.tag == "BuildableZone")
                    {
                        if (intComponentWall != null && extComponentWall != null)
                        {
                            GameObject newWallTrim = Instantiate(db.GetStoreObject(9999, 0).gameObject_);
                            newWallTrim.transform.parent = extComponentWall.transform;
                            //Vector3 pos = componentWall.transform.position;
                            //Vector3 trimPos = new Vector3(pos.x, .02f, pos.z);
                            //newWallTrim.transform.position = trimPos + new Vector3(0, 0, -0.05f);
                            //newWallTrim.transform.eulerAngles = componentWall.gameObject.transform.eulerAngles;
                            //newWallTrim.transform.localScale = new Vector3(1, 2, .1f);
                        }
                    }
                }
            }

            // Top Row
            if (node.gridX == grid.gridSizeX - 1)
            {
                ComponentWall intComponentWall = CreateTopWall(grid, node, intWallID, true);
                ComponentWall extComponentWall = CreateTopWall(grid, node, extWallID, false);
                RaycastHit    hit;
                if (Physics.Raycast(intComponentWall.raycastObject.transform.position, Vector3.down, out hit))
                {
                    FloorTile np = hit.transform.gameObject.GetComponent <FloorTile>();
                    if (np != null)
                    {
                        if (np.node.componentEdge)
                        {
                            if (np.component != parentWalls.gameObject.name)
                            {
                                Destroy(extComponentWall.gameObject); // dont do an external wall if theres another component over there
                                if (parentWalls.showingTransparency)
                                {
                                    Destroy(intComponentWall.gameObject);                      // Destroy solid wall
                                    intComponentWall = CreateTopWall(grid, node, 12000, true); // Make a trans wall (it identifies as male)
                                }
                            }
                            else if (np.component == parentWalls.gameObject.name)
                            {
                                Destroy(intComponentWall.gameObject); // Destroy wall
                                Destroy(extComponentWall.gameObject); // Destroy wall
                            }
                        }
                    }
                    if (hit.transform.tag == "BuildableZone")
                    {
                        if (intComponentWall != null && extComponentWall != null)
                        {
                            GameObject newWallTrim = Instantiate(db.GetStoreObject(9999, 0).gameObject_);
                            newWallTrim.transform.parent = extComponentWall.transform;
                            //Vector3 pos = componentWall.transform.position;
                            //Vector3 trimPos = new Vector3(pos.x, .02f, pos.z);
                            //newWallTrim.transform.position = trimPos + new Vector3(0, 0, -0.05f);
                            //newWallTrim.transform.eulerAngles = componentWall.gameObject.transform.eulerAngles;
                            //newWallTrim.transform.localScale = new Vector3(1, 2, .1f);
                        }
                    }
                }
            }

            // Bottom Row
            if (node.gridX == 0)
            {
                ComponentWall intComponentWall = CreateBottomWall(grid, node, intWallID, true);
                ComponentWall extComponentWall = CreateBottomWall(grid, node, extWallID, false);
                RaycastHit    hit;
                if (Physics.Raycast(intComponentWall.raycastObject.transform.position, Vector3.down, out hit))
                {
                    FloorTile np = hit.transform.gameObject.GetComponent <FloorTile>();
                    if (np != null)
                    {
                        if (np.node.componentEdge)
                        {
                            if (np.component != parentWalls.gameObject.name)
                            {
                                Destroy(extComponentWall.gameObject); // dont do an external wall if theres another component over there
                                if (parentWalls.showingTransparency)
                                {
                                    Destroy(intComponentWall.gameObject);                         // Destroy solid wall
                                    intComponentWall = CreateBottomWall(grid, node, 12000, true); // Make a trans wall (it identifies as male)
                                }
                            }
                            else if (np.component == parentWalls.gameObject.name)
                            {
                                Destroy(intComponentWall.gameObject); // Destroy wall
                                Destroy(extComponentWall.gameObject); // Destroy wall
                            }
                        }
                    }
                    if (hit.transform.tag == "BuildableZone")
                    {
                        if (intComponentWall != null && extComponentWall != null)
                        {
                            GameObject newWallTrim = Instantiate(db.GetStoreObject(9999, 0).gameObject_);
                            newWallTrim.transform.parent = extComponentWall.transform;
                            //Vector3 pos = componentWall.transform.position;
                            //Vector3 trimPos = new Vector3(pos.x, .02f, pos.z);
                            //newWallTrim.transform.position = trimPos + new Vector3(0, 0, -0.05f);
                            //newWallTrim.transform.eulerAngles = componentWall.gameObject.transform.eulerAngles;
                            //newWallTrim.transform.localScale = new Vector3(1, 2, .1f);
                        }
                    }
                }
            }
        }
    }