Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

            Ball b = new Ball();

            spriteManager.Add(b);
            MovingWall w = new MovingWall();

            for (int i = 0; i < 50; i++)
            {
                w.Position = new Vector2((float)random.NextDouble() * 800f, (float)random.NextDouble() * 600f);
                spriteManager.Add(w);

                if (CollisionManager.Find(w) != null)
                {
                    spriteManager.Remove(w);
                }

                w = new MovingWall();
            }

            BrokenWall e = new BrokenWall();

            for (int i = 0; i < 50; i++)
            {
                e.Position = new Vector2((float)random.NextDouble() * 800f, (float)random.NextDouble() * 600f);
                spriteManager.Add(e);

                if (CollisionManager.Find(e) != null)
                {
                    spriteManager.Remove(e);
                }

                e = new BrokenWall();
            }

            Wall ww = new Wall();

            for (int i = 0; i < 50; i++)
            {
                ww.Position = new Vector2((float)random.NextDouble() * 800f, (float)random.NextDouble() * 600f);
                spriteManager.Add(ww);

                if (CollisionManager.Find(ww) != null)
                {
                    spriteManager.Remove(ww);
                }

                ww = new Wall();
            }
        }
    //Player moving when on a moving wall / platform
    private void OnCollisionStay(Collision col)
    {
        if (col.gameObject.GetComponent <MovingWall>())
        {
            MovingWall wall         = col.gameObject.GetComponent <MovingWall>();
            Vector3    WallMovement = wall.GetDirectionXSpeed();

            if (wall.IsMovingOut)
            {
                WallMovement *= -1;
            }

            if (wall.IsWallOutOfPosition())
            {
                transform.position += WallMovement;
            }
        }
    }
Exemple #3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        MovingWall wall = (MovingWall)target;

        if (wall.draggable == null)
        {
            wall.draggable = wall.GetComponent <GridDraggableObject>();
        }
        if (GUILayout.Button("Установить как точку прибытия"))
        {
            wall.toPosition = new GridObject.Position()
            {
                xCell = wall.draggable.position.xCell,
                yRow  = wall.draggable.position.yRow
            };
        }
        if (!Application.isPlaying)
        {
            EditorUtility.SetDirty(wall);
        }
    }
    // METHODS
    // Use this for initialization
    void Start()
    {
        minimap = Camera.allCameras[1];
        minimap.gameObject.SetActive(false);

        chamberWallScript = GameObject.Find("Sealing Door").GetComponent <MovingWall>();
        startingHallway   = GameObject.Find("Starting Hallway");

        totalRooms      = new ArrayList();
        totalRoomCoords = new ArrayList();

        totalRooms.Add(GameObject.Find("Burial Chamber"));
        totalRoomCoords.Add(((GameObject)totalRooms[0]).transform.position);

        numRooms        = 0;
        doors           = 0;
        discoveredRooms = 0;
        scoreText.text  = discoveredRooms.ToString();

        hallways   = new ArrayList();
        oneRooms   = new ArrayList();
        twoRooms   = new ArrayList();
        threeRooms = new ArrayList();
        fourRooms  = new ArrayList();

        rooms = new ArrayList();
        rooms.Add(Room_0);
        rooms.Add(Room_1);
        rooms.Add(Room_2);
        rooms.Add(Room_3);
        rooms.Add(Room_4);
        rooms.Add(Room_5);
        rooms.Add(Room_6);
        rooms.Add(Room_7);
        rooms.Add(Room_8);
        rooms.Add(Room_9);
        rooms.Add(Room_10);
        rooms.Add(Room_11);
        rooms.Add(Room_12);
        rooms.Add(Room_13);
        rooms.Add(Room_14);
        rooms.Add(Room_15);
        rooms.Add(Room_16);
        rooms.Add(Room_17);


        // Assign directions associated with each room type, based on their tag
        adjacentRooms = new ArrayList();
        for (int i = 0; i < rooms.Count; i++)
        {
            if (rooms[i] != null)
            {
                adjacentRooms.Add(GetRoomDirections((GameObject)rooms[i]));
            }
        }


        // Assign the North, East, South, and West rooms
        northRooms = new ArrayList();
        eastRooms  = new ArrayList();
        southRooms = new ArrayList();
        westRooms  = new ArrayList();
        nRooms     = new ArrayList();
        eRooms     = new ArrayList();
        sRooms     = new ArrayList();
        wRooms     = new ArrayList();
        neRooms    = new ArrayList();
        nsRooms    = new ArrayList();
        ewRooms    = new ArrayList();
        seRooms    = new ArrayList();
        swRooms    = new ArrayList();
        nwRooms    = new ArrayList();
        newRooms   = new ArrayList();
        nesRooms   = new ArrayList();
        eswRooms   = new ArrayList();
        nswRooms   = new ArrayList();
        neswRooms  = new ArrayList();

        for (int i = 0; i < rooms.Count; i++)
        {
            AdjacentDirections a = (AdjacentDirections)adjacentRooms[i];

            // Classify rooms that are hallways
            if (((GameObject)rooms[i]).GetComponent <HallwayRoom>() != null)
            {
                hallways.Add((GameObject)rooms[i]);
            }

            // Rooms that contain this direction door
            if (HasFlag(a, AdjacentDirections.N))
            {
                northRooms.Add((GameObject)rooms[i]);
            }

            if (HasFlag(a, AdjacentDirections.E))
            {
                eastRooms.Add((GameObject)rooms[i]);
            }

            if (HasFlag(a, AdjacentDirections.S))
            {
                southRooms.Add((GameObject)rooms[i]);
            }

            if (HasFlag(a, AdjacentDirections.W))
            {
                westRooms.Add((GameObject)rooms[i]);
            }


            // Four directions
            if (a == (AdjacentDirections.N | AdjacentDirections.E | AdjacentDirections.S | AdjacentDirections.W))
            {
                neswRooms.Add((GameObject)rooms[i]);
                fourRooms.Add((GameObject)rooms[i]);
            }


            // Three directions
            else if (a == (AdjacentDirections.N | AdjacentDirections.E | AdjacentDirections.W))
            {
                newRooms.Add((GameObject)rooms[i]);
                threeRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.N | AdjacentDirections.E | AdjacentDirections.S))
            {
                nesRooms.Add((GameObject)rooms[i]);
                threeRooms.Add((GameObject)rooms[i]);
            }

            else if (HasFlag(a, (AdjacentDirections.E | AdjacentDirections.S | AdjacentDirections.W)))
            {
                eswRooms.Add((GameObject)rooms[i]);
                threeRooms.Add((GameObject)rooms[i]);
            }

            else if (HasFlag(a, (AdjacentDirections.N | AdjacentDirections.S | AdjacentDirections.W)))
            {
                nswRooms.Add((GameObject)rooms[i]);
                threeRooms.Add((GameObject)rooms[i]);
            }


            // Two directions
            else if (a == (AdjacentDirections.N | AdjacentDirections.E))
            {
                neRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.N | AdjacentDirections.S))
            {
                nsRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.E | AdjacentDirections.W))
            {
                ewRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.S | AdjacentDirections.E))
            {
                seRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.S | AdjacentDirections.W))
            {
                swRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }

            else if (a == (AdjacentDirections.N | AdjacentDirections.W))
            {
                nwRooms.Add((GameObject)rooms[i]);
                twoRooms.Add((GameObject)rooms[i]);
            }


            // Single Directions
            else if (a == AdjacentDirections.N)
            {
                nRooms.Add((GameObject)rooms[i]);
                oneRooms.Add((GameObject)rooms[i]);
            }

            else if (a == AdjacentDirections.E)
            {
                eRooms.Add((GameObject)rooms[i]);
                oneRooms.Add((GameObject)rooms[i]);
            }

            else if (a == AdjacentDirections.S)
            {
                sRooms.Add((GameObject)rooms[i]);
                oneRooms.Add((GameObject)rooms[i]);
            }

            else if (a == AdjacentDirections.W)
            {
                wRooms.Add((GameObject)rooms[i]);
                oneRooms.Add((GameObject)rooms[i]);
            }
        }

        score0 = "";
        score1 = "";
        score2 = "";
        score3 = "";
    }
 private void Awake()
 {
     component = wall.GetComponent <MovingWall>();
     InvokeRepeating("IncreaseSpeed", 5f, 3f);
 }