Exemplo n.º 1
0
    private static void SetNewMaxTowers(int numberOfNewTowers)
    {
        GameObject   world     = GameObject.Find("World");
        TowerFactory newTowers = world.GetComponent <TowerFactory>();

        newTowers.maxTowers = numberOfNewTowers;
    }
Exemplo n.º 2
0
 public void BuyPlaceTower(TowerTypes type)
 {
     if (!towers.ContainsKey(selectedTile) && CurrentPlayer.WithdrawalMoney(TowerFactory.GetTowerCost(type)))
     {
         towers.Add(selectedTile, TowerFactory.GetTower(type, new Vector2(selectedTile.X * TileDimensions.X, selectedTile.Y * TileDimensions.Y)));
     }
 }
Exemplo n.º 3
0
    private void Start()
    {
        float cameraX = Camera.main.orthographicSize * Screen.width / Screen.height;
        float cameraY = Camera.main.orthographicSize;

        cameraXBound = new Bounds(-cameraX, cameraX);
        cameraYBound = new Bounds(-cameraY, cameraY);

        ColdCry.Graphic.Graphics.LoadGraphics();
        tower = TowerFactory.GetInstance();

        Subscribe(tower);

        innerMask = GameObject.Find("Mask").GetComponent <SpriteMask>();
        outerMask = GameObject.Find("Mask_Platform").GetComponent <SpriteMask>();

        // humanPlayer = PlayersFactory.GetHumanPlayer();
        hairPlayer = PlayersFactory.GetHairPlayer();

        hairPlayer.GetComponent <HairMove>().Tower = tower;

        humanPlayer = GameObject.Find("PlayerMainPrefab");

        // Vector3 firstPlatformPos = tower.GetLowestPlatform( 1 ).transform.position;
        //humanPlayer.transform.position = firstPlatformPos + new Vector3( 0, 0.25f );



        // Timers initialization
        Instance.gameTimerId = TimerManager.Create(easyTimer, this);
    }
Exemplo n.º 4
0
 protected override void OnRelease()
 {
     TowerFactory.createTower(towerIdx, toSpawnPosInCell, GameObject.Find("MapLayer").transform);
     sprite           = null;
     v                = Vector3Int.zero;
     toSpawnPosInCell = Vector2Int.zero;
 }
    public void UpdateState(TowerSpawnerViewModel data)
    {
        if (towerProjection != null)
        {
            Destroy(towerProjection);
        }
        Tower           model = ElementalTowerDefenseModel.TowerFactory.CreateTower(data.TowerType);
        TowerController controller
            = TowerFactory.CreateTower(
                  data.TowerType,
                  model,
                  null,
                  out towerProjection);

        towerProjection.GetComponent <Rigidbody>().detectCollisions = false;
        towerProjection.GetComponent <TowerView>().enabled          = false;
        towerProjection.transform.parent           = gameObject.transform;
        transform.GetChild(0).transform.localScale = new Vector3(
            model.Range.Points * 2,
            model.Range.Points * 2,
            model.Range.Points * 2);
        spawnerView.IsInSpawnMode = data.IsInSpawnMode;

        if (!IsInSpawnMode)
        {
            SetProjectionVisibility(false);
        }
    }
Exemplo n.º 6
0
        public override void HandleInput()
        {
            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                new MenuPause(SceneManager, this).Add();
                return;
            }

            if (GlobalsVar.PlayerLife <= 0)
            {
                new MenuGameOver(SceneManager, this).Add();
                return;
            }

            Vector2?clickObject = CheckMouse();

            if (clickObject != null)
            {
                towers.Add(TowerFactory.GenerateTower(gameInterface.TowerSelectedType, new Vector3(clickObject.Value.X * 5, clickObject.Value.Y * 5, 0)));
                towers.Sort(Comparers.TowerCompareY);
            }

            gameBackground.HandleInput();
            gameInterface.HandleInput();
        }
Exemplo n.º 7
0
        private void CreateButtons(TowerSelectorController towerSelector)
        {
            // Tower1
            Buttons.Add(new TowerButton(
                            ButtonsOffset + new Vector2(10f, 30f),
                            new Vector2(100f, 80f),
                            TowerFactory.GetTower("Tower1"),
                            new Rectangle(0, 0, 100, 60),
                            200)
            {
                TextPosition   = new Vector2(50f, 70f),
                AttachedObject = "Tower1"
            });
            // Tower2
            Buttons.Add(new TowerButton(
                            ButtonsOffset + new Vector2(120f, 30f),
                            new Vector2(100f, 80f),
                            TowerFactory.GetTower("Tower2"),
                            new Rectangle(0, 0, 100, 60),
                            200)
            {
                TextPosition   = new Vector2(50f, 70f),
                AttachedObject = "Tower2"
            });

            foreach (Button button in Buttons)
            {
                button.OnClicked += towerSelector.OnTowerButtonClicked;
            }
        }
Exemplo n.º 8
0
 void OnMouseOver()
 {
     if (Input.GetMouseButtonDown(0) && isPlaceable)
     {
         TowerFactory towerFactory = FindObjectOfType <TowerFactory>();
         towerFactory.PlaceTower(this);
     }
 }
Exemplo n.º 9
0
 private void Awake()
 {
     if (Instance != null)
     {
         throw new ColdCry.Exception.SingletonException("There can be only one object of TowerFactory on scene!");
     }
     Instance = this;
 }
Exemplo n.º 10
0
 public TowerCommand(TowerFactory factory, Point location, TowerTypes towerType)
 {
     this._factory   = factory;
     this._location  = location;
     this._towerType = towerType;
     this._singleton = DebugLogSingleton.GetInstance();
     this._singleton.Log <TowerCommand>("Command", "Initializing tower command");
 }
Exemplo n.º 11
0
    public void LoadGame(LevelFile level, TowerFactory towerFactory, UnitFactory unitFactory, Action <float> onProgress)
    {
        this.level        = level;
        this.towerFactory = towerFactory;
        this.unitFactory  = unitFactory;
        loadProgress      = onProgress;

        SetState(State.Loading);
    }
Exemplo n.º 12
0
    void Awake()
    {
        towerFactory = FindObjectOfType <TowerFactory>();
        towerUI      = FindObjectOfType <TowerUI>();

        GrassTileClick.OnGrassTileClicked += towerFactory.PlaceTower;
        GrassTileClick.OnGrassTileClicked += ToggleTowerUIinactive;

        GrassTileClick.OnTowerClicked += towerUI.SetPosition;
        GrassTileClick.OnTowerClicked += ToggleTowerUIActive;
    }
Exemplo n.º 13
0
 public GameLevel(GameLevelSettings settings, EnemyFactory enemyFactory, GamePhaseManager gamePhaseManager,
                  InputManager inputManager, TowerFactory towerFactory)
 {
     _settings                   = settings;
     _enemyFactory               = enemyFactory;
     _gamePhaseManager           = gamePhaseManager;
     _inputManager               = inputManager;
     _towerFactory               = towerFactory;
     inputManager.OnKeyReleased += InputManagerOnOnKeyReleased;
     inputManager.OnClick       += InputManagerOnOnClick;
 }
Exemplo n.º 14
0
    IEnumerator Start()
    {
        unitFactory  = Instantiate(unitFactory);
        towerFactory = Instantiate(towerFactory);

        // TODO: Improve loading bar progress so it feels more natural.
        yield return(StartCoroutine(LoadOfficialLevels()));

        yield return(StartCoroutine(LoadCustomLevels()));

        yield return(StartCoroutine(LaunchMenu()));
    }
Exemplo n.º 15
0
    public void SetDefence(TowerFactory towerFactory, int usedBudget)
    {
        IANTGame.Player.DefenceDataString = towerFactory.SerializeTowers();
        IANTGame.Player.UsedDefenceBudget = usedBudget;
        var parameter = new Dictionary <byte, object>()
        {
            { (byte)SetDefenceParameterCode.DefenceDataString, IANTGame.Player.DefenceDataString },
            { (byte)SetDefenceParameterCode.UsedBudget, usedBudget }
        };

        IANTGame.Service.SendOperation(OperationCode.SetDefence, parameter);
    }
Exemplo n.º 16
0
    public void showConstructionGUI(TowerFactory aTowerFactory)
    {
        TowerCreationPanel.show();
        var buttonArray = TowerCreationPanel.transform.Cast <Transform>().Where(c => c.gameObject.tag == "TowerButtons").Select(c => c.gameObject).ToArray();

        for (int i = 0; i < buttonArray.Length; i++)
        {
            GameObject          aButton = buttonArray[i];
            TowerCreationButton aTCB    = aButton.GetComponent <TowerCreationButton>();
            aTCB.TowerFactory = aTowerFactory;
        }
    }
Exemplo n.º 17
0
        public Projectile(WeaponStats stats, Creep targetCreep, Vector2 startPoint, TowerTypes parentTowerType)
        {
            Stats       = stats.GetCopy();
            TargetCreep = targetCreep;

            CenterPosition = startPoint;

            this.type      = SelectTypeBasedOnTowerType(parentTowerType);
            this.TextureID = TowerFactory.GetProjectileMediaID(type);

            this.numFrames = ProjectileDefinitions.ProjectileStats[type].NumFrames;
        }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     towerFactory = FindObjectOfType <TowerFactory>();
     singleton    = Singleton.Instance;
     if (singleton.towerTwoBase != null)
     {
         buttonName2.text = (singleton.towerTwoBase.name + "   cost: " + singleton.towerTwoBase.GetTowerCost().ToString());
     }
     else
     {
         buttonName2.text = "Unassigned";
     }
 }
Exemplo n.º 19
0
        public TestScreen()
        {
            camera = new Camera(new Vector2(0, 0))
            {
                Scale = new Vector2(0.8f)
            };

            enemyManager          = new EnemyManager();
            towerManager          = new TowerManager(enemyManager);
            bulletManager         = new BulletManager(enemyManager);
            particleManager       = new ParticleManager();
            towerPlacer           = new TowerPlacer(towerManager);
            selectTowerController = new SelectTowerController(towerManager, towerPlacer, camera);
            spawnerController     = new EnemySpawnerController(enemyManager);
            TowerSelectorController towerSelector = new TowerSelectorController(camera, towerPlacer, bulletManager, enemyManager, particleManager);

            // Create Tower prefabs.
            TowerFactory.Add("Tower1", new TestTower(bulletManager, enemyManager, particleManager));
            TowerFactory.Add("Tower2", new MachineGunPlaneTower(bulletManager, enemyManager, particleManager));

            enemyManager.OnEnemyReachedLastPoint += OnEnemyReachedGoal;

            // Controllers.
            controllers.Add(selectTowerController);
            controllers.Add(new MapMoverController(camera));
            controllers.Add(spawnerController);
            controllers.Add(enemyManager);
            controllers.Add(towerManager);
            controllers.Add(bulletManager);
            controllers.Add(particleManager);
            controllers.Add(towerSelector);
            //controllers.Add(new TestTowerPlacerScript(towerPlacer, TowerFactory.GetTower("Tower2"))); // TEST!

            // Views.
            views.Add(new SelectedTowerView(selectTowerController));
            views.Add(new MapView());
            views.Add(enemyManager);
            views.Add(towerManager);
            views.Add(bulletManager);
            views.Add(particleManager);

            AvailableTowersUiView availableTowersUi = new AvailableTowersUiView(new ButtonManager(), towerSelector, new Rectangle(700, 0, 300, 550));

            MouseOverlapsUI.AvailableTowersUi = availableTowersUi;

            // UI.
            uiViews.Add(availableTowersUi);

            spawnerController.Enabled = false;
        }
Exemplo n.º 20
0
 protected void HandleTowerLoop()
 {
     foreach (Tower t in towers.Values)
     {
         t.Update();
         Creep target;
         if (t.CanFire && Calculator.BestShootableCreep(creeps, t.Position, t.GetTowerStats().Range, out target))
         {
             var proj = TowerFactory.GetTowerProjectile(t, target);
             target.DeathForecast += proj.Stats.Damage;
             projectileManager.AddProjectile(proj);
         }
     }
 }
Exemplo n.º 21
0
 public void SpawnTower()
 {
     if (View.TowerIsPlaceable)
     {
         Tower tower = towerService.Buy();
         if (tower != null)
         {
             TowerController controller = TowerFactory.CreateTower(Model.SelectedTowerType, tower, this);
             goldManagerController.UpdateView();
             controllers.Add(controller);
             IsInSpawnMode = false;
         }
     }
 }
Exemplo n.º 22
0
    void Awake()
    {
        Utils.Log("TowerFactory:Awake");

        instance = this;
        towerTypes.Add(GameObject.Find("TowerType0"));
        towerTypes.Add(GameObject.Find("TowerType1"));
        towerTypes.Add(GameObject.Find("TowerType2"));
        towerTypes.Add(GameObject.Find("TowerType3"));
        towerTypes.Add(GameObject.Find("TowerType4"));
        for (int i = 0; i < towerTypes.Count; i++)
        {
            towerTypes[i].SetActive(false);
        }
    }
Exemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     towerFactory = FindObjectOfType <TowerFactory>();
     singleton    = Singleton.Instance;
     if (singleton.towerOneBase != null)
     {
         buttonName1.text = (singleton.towerOneBase.name + "   cost: " + singleton.towerOneBase.GetTowerCost().ToString());
     }
     else
     {
         // first button defaults to rifled tower
         buttonName1.text = "Basic Rifled Tower: 50";
         //buttonName1.text = "Unassigned";
     }
 }
Exemplo n.º 24
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("TowerFactory: multiple instances.");
            return;
        }

        instance = this;
        data     = new Tower.Data[prefabs.Length];
        for (int i = 0; i < data.Length; ++i)
        {
            data[i] = prefabs[i].data;
        }
    }
    //private bool created = false;

    void Awake()
    {
        tower = TowerFactory.CreateTower(tower);

        if (tower.bulletPrefab != null)
        {
            PoolManager.CheckForPool(tower.bulletPrefab, 500);
        }

        /*if (!created)
         * {
         *  DontDestroyOnLoad(gameObject);
         *  created = true;
         *  //Debug.Log("Awake: " + gameObject);
         * }*/
    }
Exemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        towerFactory = FindObjectOfType <TowerFactory>();
        singleton    = Singleton.Instance;
        //try
        //{
        //    buttonName3.text = singleton.towerThree.buttonName;
        //}
        //catch (Exception e)
        //{
        //    // no buttonName, then it is unassigned as of yet.
        //    buttonName3.text = "Unassigned";
        //}

        if (singleton.towerThreeBase != null)
        {
            buttonName3.text = (singleton.towerThreeBase.name + "   cost: " + singleton.towerThreeBase.GetTowerCost().ToString());
        }
        else
        {
            buttonName3.text = "Unassigned";
        }
    }
Exemplo n.º 27
0
        public void OnTowerButtonClicked(object obj, EventArgs args)
        {
            string towerName = ((Button)obj).AttachedObject as string;

            towerPlacer.TargetTower = TowerFactory.GetTower(towerName);
        }
Exemplo n.º 28
0
 private void Start()
 {
     towerFactory = FindObjectOfType <TowerFactory>();
 }
Exemplo n.º 29
0
 private void OnDestroy()
 {
     _instance = null;
 }
Exemplo n.º 30
0
    private void Awake()
    {
        _instance = this;

        towerStatGetter.Init();
    }