public void Initialize() { uiHandler = GetComponent <UIHandler>(); gameManager = GetComponent <GameManager>(); scenarioLoader = GetComponent <ScenarioLoader>(); outcomeVisualizer = new OutcomeVisualizer(GetComponent <PathVisualizer>()); outcomeExecutor = new OutcomeExecutor(this); outcomeAnimator = new OutcomeAnimator(this, uiHandler); selectionReachableHexes = new HashSet <HexEntry>(); enemyReachableHexes = new List <HexEntry>(); UpdateUnitList(); uiHandler.SlideCameraToHexAvg(UnitsByPlayer[gameManager.ActivePlayer].Select(x => x.Position).ToList()); turnsOfPlay = 0; scenarioLoader.SetTurnsRemainingText(Config.turnsBeforePlayer1Wins - turnsOfPlay + 1); gameManager.AITryAITurn(); if (gameManager.NetEnemyTurn()) // Netcode { uiHandler.NotYourTurn(); } }
public void Initialize(IMover mover, OutcomeAnimator outcomeAnimator, UnitSpriteManager unitSpriteManager, HexEntry startPosition) { this._mover = mover; this._outcomeAnimator = outcomeAnimator; this._unitSpriteManager = unitSpriteManager; RecentPath = new List <HexEntry>(); Position = startPosition; unitSpriteManager.VisiblePosition = Position; HP = UnitBaseStats.HP(UnitType); SpriteManager.MaxHealthDisplay = HP; // Instantiate the health bar sizing for the unit, maxHP must be first SpriteManager.CurrentHealthDisplay = HP; TurnEndUpkeep(); TurnStartUpkeep(); UnitType = _unitType; // Gives spritemanager unit-type data WeaponType = _weaponType; PlayerOwner = _playerOwner; }
public IUnitController Create(int playerOwner, UnitBaseType type, WeaponType weapon, HexEntry startPosition) { if (gameManager == null) { gameManager = GetComponent <GameManager>(); scenarioLoader = GetComponent <ScenarioLoader>(); selectionManager = GetComponent <SelectionManager>(); uiHandler = GetComponent <UIHandler>(); } GameObject unit = Instantiate(unitPrefab, Vector3.zero, Quaternion.identity); IUnitController unitController = new DefaultUnitController(type, weapon, playerOwner); UnitSpriteManager unitSpriteManager = unit.GetComponent <UnitSpriteManager>(); unitSpriteManager.UnitController = unitController; IMover mover = new DefaultMover(unitController, gameManager, selectionManager, scenarioLoader); OutcomeAnimator outcomeAnimator = new OutcomeAnimator(selectionManager, uiHandler); unitController.Initialize(mover, outcomeAnimator, unitSpriteManager, startPosition); switch (weapon) { case WeaponType.None: unitController.Weapon = new EmptyWeapon(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Spear: unitController.Weapon = new Spear(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Sword: unitController.Weapon = new Sword(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Axe: unitController.Weapon = new Axe(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Quarterstaff: unitController.Weapon = new Quarterstaff(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Flail: unitController.Weapon = new Flail(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Dagger: unitController.Weapon = new Dagger(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Longbow: unitController.Weapon = new Longbow(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Crossbow: unitController.Weapon = new Crossbow(unitController, gameManager, scenarioLoader, selectionManager); break; case WeaponType.Shield: unitController.Weapon = new Shield(unitController, gameManager, scenarioLoader, selectionManager); break; } return(unitController); }