Esempio n. 1
0
        //Moves a given wall spawner to the new position
        public static void MoveWallSpawner(WallSpawner WallSpawner, TileSpawner ReferenceTileSpawner, Vector2Int Direction, Vector2Int Rotation)
        {
            if (CanMoveWallSpawner(ReferenceTileSpawner, Direction, Rotation) && WallSpawner != null)
            {
                ReferenceTileSpawner.WallSpawnerDict[Direction] = WallSpawner; //Reference this in the reference tile
                TileSpawner OppositeTileSpawner = null;

                //Checks if the tileSpawner on the other side of the wallSpawner is inside the room
                if (Methods.IsInsideRoom(ReferenceTileSpawner.Structure.Width, ReferenceTileSpawner.Structure.Height, ReferenceTileSpawner.X + Direction.x, ReferenceTileSpawner.Y + Direction.y))
                {
                    //Find the tile on the other side of the wallSpawner
                    OppositeTileSpawner = ReferenceTileSpawner.Structure.TileSpawnerArray[ReferenceTileSpawner.X + Direction.x, ReferenceTileSpawner.Y + Direction.y];
                    OppositeTileSpawner.WallSpawnerDict[Direction * -1] = WallSpawner; //Reference this in the opposite tile
                }

                if (Direction == Rotation)
                {
                    WallSpawner.FrontTileSpawner = OppositeTileSpawner;
                    WallSpawner.BackTileSpawner  = ReferenceTileSpawner;
                }
                else
                {
                    WallSpawner.FrontTileSpawner = ReferenceTileSpawner;
                    WallSpawner.BackTileSpawner  = OppositeTileSpawner;
                }
                WallSpawner.Rotation = Rotation;
            }
        }
Esempio n. 2
0
    //シーン読み込み時に各種コンポーネントを取得するメソッド
    public void LoadComponents()
    {
        if (moveSceneManager.SceneName == "Title")
        {
            return;
        }

        wallSpawner   = GameObject.FindGameObjectWithTag("WallSpawner").GetComponent <WallSpawner>();
        mileageText   = GameObject.Find(mileageTextName).GetComponent <Text>();
        scoreText     = GameObject.Find(scoreTextName).GetComponent <Text>();
        highScoreText = GameObject.Find(highScoreTextName).GetComponent <Text>();
        levelText     = GameObject.Find(levelTextName).GetComponent <Text>();

        //追加その2
        gameOverCanvas = GameObject.Find(gameOverCanvasName).GetComponent <Canvas>();
        retryButton    = GameObject.Find(retryButtonName).GetComponent <Button>();

        //追加その3
        countdownText = GameObject.Find(countDownTextName).GetComponent <Text>();

        //ボタンにクリック時の処理を登録
        retryButton.onClick.AddListener(() => Retry());

        //追加その4
        coinSpawner = GameObject.FindGameObjectWithTag("CoinSpawner").GetComponent <CoinSpawner>();
    }
Esempio n. 3
0
 public BuildingFromSpawnerGetter(
     WallSpawner wallSpawner,
     TowerSpawner towerSpawner
     )
 {
     _wallSpawner  = wallSpawner;
     _towerSpawner = towerSpawner;
 }
Esempio n. 4
0
        public TileSpawner(string Name = "", Structure Structure = null, int X = 0, int Y = 0)
        {
            this.Name            = Name;
            this.X               = X;
            this.Y               = Y;
            this.Structure       = Structure;
            this.WallSpawnerDict = new Dictionary <Vector2Int, WallSpawner>(WallSpawner.EmptyWallSpawnerDict);


            if (Structure != null)
            {
                TileSpawner OldTileSpawner = Structure.TileSpawnerArray[X, Y];
                if (OldTileSpawner != null)
                {
                    //Moves the walls that where at OldTileSpaner to this tile
                    WallSpawner UpWallSpawner    = OldTileSpawner.WallSpawnerDict[Vector2Int.up];
                    WallSpawner RightWallSpawner = OldTileSpawner.WallSpawnerDict[Vector2Int.right];
                    WallSpawner DownWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.down];
                    WallSpawner LeftWallSpawner  = OldTileSpawner.WallSpawnerDict[Vector2Int.left];

                    if (UpWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(UpWallSpawner, this, Vector2Int.up, UpWallSpawner.Rotation);
                    }
                    if (RightWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(RightWallSpawner, this, Vector2Int.right, RightWallSpawner.Rotation);
                    }
                    if (DownWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(DownWallSpawner, this, Vector2Int.down, DownWallSpawner.Rotation);
                    }
                    if (LeftWallSpawner != null)
                    {
                        Methods.MoveWallSpawner(LeftWallSpawner, this, Vector2Int.left, LeftWallSpawner.Rotation);
                    }

                    //If there already was a TileSpawner at (X,Y) with an ActorSpawner move the ActorSpawner to this
                    if (OldTileSpawner.ActorSpawner != null)
                    {
                        this.ActorSpawner = OldTileSpawner.ActorSpawner;
                        OldTileSpawner.ActorSpawner.TileSpawner = this;
                        OldTileSpawner.ActorSpawner             = null;
                    }
                    //If there already was a TileSpawner at (X,Y) with a |BlockSpawner move the BlockSpawner to this
                    if (OldTileSpawner.BlockSpawner != null && (this.ActorSpawner == null || OldTileSpawner.BlockSpawner.Solid == false))
                    {
                        this.BlockSpawner = Structure.TileSpawnerArray[X, Y].BlockSpawner;
                        OldTileSpawner.BlockSpawner.TileSpawner = this;
                        OldTileSpawner.BlockSpawner             = null;
                    }
                    OldTileSpawner.Structure = null;
                }

                Structure.TileSpawnerArray[X, Y] = this;
            }
        }
Esempio n. 5
0
 void Start()
 {
     SectionDivider = Instantiate(SectionDividerPrefab)  as GameObject;
     SectionDivider.SetActive(false);
     WallPool           = FindObjectOfType <WallPooling> ();
     WSpawner           = FindObjectOfType <WallSpawner> ();
     HazPool            = FindObjectOfType <HazardPool> ();
     LastWallSpawnerPos = WSpawner.gameObject.transform.position;
 }
Esempio n. 6
0
 // Start is called before the first frame update
 void Start()
 {
     ws                 = new WallSpawner();
     TheMainMenu        = new MainMenu();
     ThePauseMenu       = new PauseMenu();
     TheLevelSelectMenu = new LevelSelectMenu();
     Game.GameActive    = false;
     curScene           = int.Parse(SceneManager.GetActiveScene().name.Remove(0, 5));
 }
Esempio n. 7
0
    protected void Start()
    {
        instanceBuildStatus = buildStatus.Building;

        es = FindObjectOfType <EnemySpawner>();

        mg = FindObjectOfType <MeshGenerator>();
        ws = FindObjectOfType <WallSpawner>();
        pm = FindObjectOfType <PlayerMovement>();
    }
Esempio n. 8
0
            /// <summary>
            /// It is here that wall pieces are recycled from the bottom of the screen to the top
            /// When a wall falls off screen, tell the wall spawner to spawn a new wall.
            /// This removes the need to "spawn" walls on a timer, thus removing any possibility of wall gaps!
            /// </summary>
            IEnumerator Die()
            {
                pool        = GameObject.FindWithTag("WallPool").GetComponent <Pool>();
                wallSpawner = GameObject.FindObjectOfType <WallSpawner>();
                while (transform.position.y > -5)
                {
                    transform.position -= Vector3.up * 5 * Time.deltaTime;
                    yield return(null);
                }
                bool success = pool.Dispose(transform);

                if (success)
                {
                    wallSpawner.SpawnWall();
                }
                else
                {
                    Destroy(gameObject);
                }
            }
Esempio n. 9
0
    protected override void Start()
    {
        base.Start();
        //initialMovementSpeed = 3f;
        movementSpeed = initialMovementSpeed;
        SetSpeed(movementSpeed);
        health            = startingHealth;
        deathEvent       += FindObjectOfType <EnemySpawner>().tankSpawner.OnEnemyDeath;
        deathEvent       += FindObjectOfType <CoinSpawner>().ToSpawnCoin;
        enemyPassedEvent += FindObjectOfType <EnemySpawner>().tankSpawner.OnEnemyPassed;
        enemyPassedEvent += FindObjectOfType <PlayerMovement>().OnGeneralEnemyPassed;
        ws = FindObjectOfType <WallSpawner>();
        bw = FindObjectOfType <BrickWall>();

        animator = GetComponent <Animator>();
        currInfo = animator.GetCurrentAnimatorStateInfo(0);

        animatorIdleNumber = (float)UnityEngine.Random.Range(0, 2);
        SetAnimationStates(false, false);
        enemyType = "Tank";
    }
Esempio n. 10
0
 public void SetSpawner(WallSpawner spawner)
 {
     wallSpawner = spawner;
 }
Esempio n. 11
0
 // Start is called before the first frame update
 void Start()
 {
     mgmnt   = oPlane.GetComponent <GroundManagement>();
     spawner = oWallSpawner.GetComponent <WallSpawner>();
 }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     _wallSpawn      = this.GetComponent <WallSpawner> ();
     _plantZoneSpawn = this.GetComponent <PlantZoneSpawner> ();
 }
Esempio n. 13
0
        public override void Initialize()
        {
            Context.RemoveAllComponents();
            var bounds = Context.GraphicSystem.Bounds;
            var center = bounds.GetCenter();

            // Create the walls.
            var wallSpawner = new WallSpawner(Context);

            wallSpawner.Spawn();

            // Create the snakes.
            var snakes = new Snake[MaxSnakes];

            for (int i = 0; i < MaxSnakes; i++)
            {
                var snake = new Snake(Context, new KeyboardCommandReader(Context.InputSystem, KeyBinding.Default));
                snake.Initialize(center.X, center.Y + i, 5);
                snake.Died += delegate
                {
                    ChangeToGameOver();
                };
                snakes[i] = snake;
            }

            // Create the food spawner.
            FoodSpawner.Create(Context);

            bounds = Context.Bounds;

            // Score.
            // TODO: now it is prepared to only one snake.
            // We must decide if only one Score will show all snakes scores (as list)
            // or each Snake will have its own score instance.
            Score.Create(new Point(bounds.Right, bounds.Top), snakes[0], Context);

            // Portals.
            var offsetFromLeftX  = 2;
            var offsetFromRightX = -4;
            var offsetY          = 2;

            PortalBridge.Create(
                bounds.TopCenterPoint() + new Point(offsetFromRightX, offsetY),
                bounds.LeftBottomPoint() + new Point(offsetFromLeftX, -offsetY - 1),
                Pixel.Red,
                Context);

            PortalBridge.Create(
                bounds.TopCenterPoint() + new Point(offsetFromLeftX, offsetY),
                bounds.RightBottomPoint() + new Point(offsetFromRightX, -offsetY - 1),
                Pixel.Green,
                Context);

            PortalBridge.Create(
                bounds.LeftCenterPoint() + new Point(offsetFromLeftX, offsetY),
                bounds.RightCenterPoint() + new Point(offsetFromRightX, -offsetY),
                Pixel.Blue,
                Context);

            PortalBridge.Create(
                bounds.LeftCenterPoint() + new Point(offsetFromLeftX, -offsetY),
                bounds.RightCenterPoint() + new Point(offsetFromRightX, offsetY),
                Pixel.Yellow,
                Context);
        }
    // Update is called once per frame
    void Update()
    {
        if (hasFrontWall == false)           //use forloop
        {
            float distanceBehind = (GetComponent <Renderer>().bounds.size.z / 2);

            if (GameObject.FindWithTag("Player").GetComponent <Rigidbody>().position.z < (transform.position.z + distanceBehind))
            {
                int            chance = Random.Range(0, 11);
                GameObject     wallType;
                EnviromentType enviromentType = enviromentScript.Enviroment;
                if (enviromentType == EnviromentType.Castle)
                {
                    if (chance < Const_Script.NormalWallSpawn)
                    {
                        wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().normal;
                    }
                    else if (chance < Const_Script.SideWallSpawn)
                    {
                        if (Random.Range(0, 2) == 0)
                        {
                            wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().oneSideL;
                        }
                        else
                        {
                            wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().oneSideR;
                        }
                    }
                    else if (chance < Const_Script.BridgeWallSpawn)
                    {
                        wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().sides;
                    }
                    else
                    {
                        wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().tower;
                    }
                }
                else if (enviromentType == EnviromentType.Forest)
                {
                    wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().forest;
                }
                else
                {
                    wallType = GameObject.FindWithTag("Wall_Manager").GetComponent <TypesOfWalls>().caves;
                }

                Quaternion newWallRotation = transform.rotation;
                Vector3    newWallPosition = new Vector3(0, 0, (this.transform.position.z - (GetComponent <Renderer>().bounds.size.z / 2)) - (wallType.GetComponent <Renderer>().bounds.size.z / 2));
                GameObject newWall         = Instantiate(wallType, newWallPosition, newWallRotation) as GameObject;
                newWall.transform.parent = GameObject.FindWithTag("Wall_Manager").transform;
                nextWall     = newWall;
                hasFrontWall = true;

                WallSpawner script = newWall.GetComponent <WallSpawner>();
                script.previousWall     = this.gameObject;
                script.enviromentScript = this.gameObject.GetComponentInParent <EnviromentManager> ();
                enviromentScript.WallsCount--;
                enviromentScript.CheckWallCount();
            }
        }

        if (GameObject.FindWithTag("Player").transform.position.z < (this.transform.position.z - DestroyDistance - GetComponent <Renderer>().bounds.size.z / 2))
        {
            Destroy(gameObject);
        }
    }
Esempio n. 15
0
 public FireballEngine(Game1 game, int fireballCount = 15, int speedMax = 8) : base(game)
 {
     fireballs = new List <Fireball>();
     spawner   = new WallSpawner(speedMax);
     fireballs.AddRange(spawner.Spawn(game, fireballCount));
 }
Esempio n. 16
0
        //Main constructor, Makes a room based on a structure instance
        public Room(Structure Structure)
        {
            this.Height    = Structure.Height;
            this.Width     = Structure.Width;
            this.TileArray = new Tile[Width, Height];

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    //Adds grass tiles with no block or actor.
                    TileArray[x, y] = new GrassTile(this, x, y);
                }
            }

            //Goes through every TileSpawner in the structure
            for (int x = 0; x < Structure.Width; x++)
            {
                for (int y = 0; y < Structure.Height; y++)
                {
                    TileSpawner TileSpawner = Structure.TileSpawnerArray[x, y];                                 //TileSpawner at (x,y)
                    Tile        NewTile     = TileSpawner.SpawnTile(this, x, y, this.TileArray[x, y].WallDict); //Creates a new tile based on TileSpawner

                    //Create a new actor at the tile based on ActorSpawner
                    if (TileSpawner.ActorSpawner != null)
                    {
                        TileSpawner.ActorSpawner.SpawnActor(NewTile);
                    }
                    //Create a new block at the tile based on BlockSpawner
                    if (TileSpawner.BlockSpawner != null)
                    {
                        TileSpawner.BlockSpawner.SpawnBlock(NewTile);
                    }

                    //The WallSpawners to the left and bottom of the tile
                    WallSpawner LeftWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.left];
                    WallSpawner DownWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.down];

                    //Spawn a wall to the left based on LeftWallSpawner
                    if (LeftWallSpawner != null)
                    {
                        LeftWallSpawner.SpawnWall(NewTile, Vector2Int.left);
                    }
                    //Spawn a wall to the bottom based on DownWallSpawner
                    if (DownWallSpawner != null)
                    {
                        DownWallSpawner.SpawnWall(NewTile, Vector2Int.down);
                    }

                    //Walls on the top and right are only spawned on the border
                    //Otherwise walls would be initialized twice
                    if (x == Structure.Width - 1)
                    {
                        WallSpawner RightWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.right];
                        if (RightWallSpawner != null)
                        {
                            RightWallSpawner.SpawnWall(NewTile, Vector2Int.right);
                        }
                    }
                    if (y == Structure.Height - 1)
                    {
                        WallSpawner UpWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.up];
                        if (UpWallSpawner != null)
                        {
                            UpWallSpawner.SpawnWall(NewTile, Vector2Int.up);
                        }
                    }
                }
            }
        }
    public void Awake()
    {
        //config
        var terrainData = terrain.terrainData;

        int mapWidth  = terrainData.heightmapResolution;
        int mapHeight = terrainData.heightmapResolution;

        //lists
        var buildingList = new BuildingList();

        //matrices
        var mapLayerMatrixManager = new MapLayerMatrixManager();

        var mapLayerMatrixBuildings   = new MapLayerMatrix((short)mapWidth, (short)mapHeight);
        var mapLayerMatrixWalls       = new MapLayerMatrix((short)mapWidth, (short)mapHeight);
        var mapLayerMatrixWallsEditor = new MapLayerMatrix((short)mapWidth, (short)mapHeight);

        var terrainHitter = new TerrainHitter();

        cameraManager.Init(terrainHitter);
        var terrainPositionsFromCameraBoundariesGetter = new TerrainPositionsFromCameraBoundariesGetter(terrainHitter, cameraComponent);

        buildingsTypesList.Init();

        var buildingAreaGetter       = new BuildingAreaGetter(buildingsTypesList);
        var buildingMapMatrixUpdater = new BuildingMapMatrixUpdater(
            buildingAreaGetter,
            mapLayerMatrixManager,
            mapLayerMatrixBuildings
            );

        var wallSpawner = new WallSpawner(
            buildingList,
            buildingMapMatrixUpdater,
            wallData,
            mapLayerMatrixManager,
            mapLayerMatrixWalls
            );

        var towerSpawner = new TowerSpawner(buildingList, buildingMapMatrixUpdater);
        var buildingFromSpawnerGetter = new BuildingFromSpawnerGetter(wallSpawner, towerSpawner);

        var wallSidesUpdater = new WallSidesUpdater(
            mapLayerMatrixManager,
            mapLayerMatrixWallsEditor,
            mapLayerMatrixWalls
            );

        //displayers
        var buildingsDisplayer = new BuildingsDisplayer(objectPoolerManager, buildingList, wallSidesUpdater);

        objectPoolerDisplayer.Init(terrainPositionsFromCameraBoundariesGetter, buildingsDisplayer);

        var buildingCollisionDetector = new BuildingCollisionDetector(
            buildingAreaGetter,
            mapLayerMatrixManager,
            mapLayerMatrixBuildings
            );

        var buildingByTypeSpawner = new BuildingByTypeSpawner(wallSpawner, towerSpawner);

        var buildingPlacer = new BuildingPlacer(
            buildingFromSpawnerGetter,
            terrainHitter,
            cameraComponent,
            buildingList,
            buildingsDisplayer,
            buildingCollisionDetector,
            buildingByTypeSpawner,
            mapLayerMatrixManager,
            mapLayerMatrixWallsEditor
            );

        viewManager.Init(buildingsTypesList, buildingPlacer, canvas);
    }