コード例 #1
0
        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();
            }
        }
コード例 #2
0
ファイル: DefaultMover.cs プロジェクト: GBudee/deft-Sample
 public DefaultMover(IUnitController unitController, GameManager gameManager, SelectionManager selectionManager, ScenarioLoader scenarioLoader)
 {
     this.gameManager      = gameManager;
     this.unitController   = unitController;
     this.selectionManager = selectionManager;
     this.scenarioLoader   = scenarioLoader;
 }
コード例 #3
0
 public EmptyWeapon(IUnitController unitController, GameManager gameManager, ScenarioLoader scenarioLoader, SelectionManager selectionManager)
 {
     this.unitController   = unitController;
     this.gameManager      = gameManager;
     this.scenarioLoader   = scenarioLoader;
     this.selectionManager = selectionManager;
 }
コード例 #4
0
        public DefaultAI(SelectionManager selectionManager, ScenarioLoader scenarioLoader)
        {
            this.selectionManager = selectionManager;
            this.scenarioLoader   = scenarioLoader;

            MapDistancesToGoal();
        }
コード例 #5
0
ファイル: Outcome.cs プロジェクト: GBudee/deft-Sample
        public SZOutcome(SelectionManager selectionManager, ScenarioLoader scenarioLoader, Outcome toCopy)
        {
            activeUnit    = selectionManager.GetIDByUnit(toCopy.activeUnit);
            position      = scenarioLoader.GetIDByHex(toCopy.position);
            spendingMoves = toCopy.spendingMoves;

            combat = new List <SZAttackResult>();
            foreach (AttackResult attackResult in toCopy.combat)
            {
                combat.Add(new SZAttackResult(selectionManager, scenarioLoader, attackResult));
            }
        }
コード例 #6
0
        public List <IUnitController> permittedUnits; // If null, not checked

        public void Initialize()
        {
            gameManager      = GetComponent <GameManager>();
            selectionManager = GetComponent <SelectionManager>();
            scenarioLoader   = GetComponent <ScenarioLoader>();
            cameraHandler    = GetComponent <CameraHandler>();

            EnableInputs();

            cameraHandler.Initialize(scenarioLoader.HexGrid.Values
                                     .Select(x => HexVectorUtil.worldPositionOfHexCoord(x.BoardPos)).ToList(), new Vector2(0, 0), new Vector2(1, 1));
        }
コード例 #7
0
ファイル: PathVisualizer.cs プロジェクト: GBudee/deft-Sample
        // Use this for initialization
        void Start()
        {
            scenarioLoader = GetComponent <ScenarioLoader>();

            pathSegments           = new List <GameObject>();
            hitArrows              = new List <GameObject>();
            ffWarnings             = new List <GameObject>();
            rangeIndicatorSegments = new Dictionary <IUnitController, List <GameObject> >();

            pathSegmentContainer    = new GameObject("PathSegmentContainer");
            hitArrowContainer       = new GameObject("HitArrowContainer");
            rangeIndicatorContainer = new GameObject("RangeIndicatorContainer");
        }
コード例 #8
0
ファイル: Outcome.cs プロジェクト: GBudee/deft-Sample
        public AttackResult(SelectionManager selectionManager, ScenarioLoader scenarioLoader, SZAttackResult toCopy)
        {
            target          = selectionManager.GetUnitByID(toCopy.target);
            source          = selectionManager.GetUnitByID(toCopy.source);
            healthRemaining = toCopy.healthRemaining;
            sourceHex       = scenarioLoader.GetHexByID(toCopy.sourceHex);
            targetHex       = scenarioLoader.GetHexByID(toCopy.targetHex);
            attackType      = toCopy.attackType;

            if (toCopy.pushMoves == null)
            {
                pushMoves = null;
            }
            else
            {
                pushMoves = new List <Outcome>();
                foreach (SZOutcome outcome in toCopy.pushMoves)
                {
                    pushMoves.Add(new Outcome(selectionManager, scenarioLoader, outcome));
                }
            }
        }
コード例 #9
0
ファイル: Axe.cs プロジェクト: GBudee/deft-Sample
 public Axe(IUnitController unitController, GameManager gameManager, ScenarioLoader scenarioLoader, SelectionManager selectionManager) : base(unitController, gameManager, scenarioLoader, selectionManager)
 {
 }
コード例 #10
0
ファイル: UnitFactory.cs プロジェクト: GBudee/deft-Sample
        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);
        }
コード例 #11
0
        }                                     // The player whose turn it currently is

        void Start()
        {
            // Cache major scripts to be initialized
            scenarioLoader   = GetComponent <ScenarioLoader>();
            uiHandler        = GetComponent <UIHandler>();
            selectionManager = GetComponent <SelectionManager>();
            unitFactory      = GetComponent <UnitFactory>();

            // Load map, then camera
            scenarioLoader.Initialize();
            uiHandler.Initialize();


            // Establish player types, network information
            GameObject matchControllerObject = GameObject.Find("MatchController");

            if (matchControllerObject != null)
            {
                matchController = matchControllerObject.GetComponent <Netcode.MatchController>();
            }
            if (matchController != null)
            {
                playerDirectory = new Dictionary <int, PlayerType>();
                foreach (int player in matchController.netRepPlayers.Keys)
                {
                    if (matchController.whoAmI == player)
                    {
                        playerDirectory.Add(player, PlayerType.Local);
                    }
                    else
                    {
                        playerDirectory.Add(player, PlayerType.Online);
                    }
                }
            }
            else if (Vaults.playerDirectory != null)
            {
                playerDirectory = Vaults.playerDirectory;
            }
            else
            {
                Debug.Log("Using default playerDirectory");
                playerDirectory = new Dictionary <int, PlayerType>();
                playerDirectory.Add(1, PlayerType.Local);
                playerDirectory.Add(2, PlayerType.AI); // FOR TESTING__, these defaults shouldn't be reached
            }

            Tutorial.TutorialManager tutorialManager = GetComponent <Tutorial.TutorialManager>();
            if (tutorialManager != null)
            {
                computerPlayer = new Tutorial.TutorialAI(tutorialManager, selectionManager, scenarioLoader);
            }
            else if (playerDirectory.Values.Contains(PlayerType.AI))
            {
                computerPlayer = new DefaultAI(selectionManager, scenarioLoader);
            }
            ActivePlayer = 1;

            // Build & load units onto the map
            if (Vaults.wsUnitList != null)
            {
                foreach (WeaponSelect.WSController.WSUnitDescriptor unit in Vaults.wsUnitList)
                {
                    unitFactory.Create(unit.player, unit.unitType, unit.weaponType, scenarioLoader.HexGrid[unit.position]);
                }
            }
            else   // FOR TESTING

            /*
             * unitFactory.Create(1, UnitBaseType.Simple, WeaponType.Longbow, GetComponent<ScenarioLoader>().HexGrid[new Vector2(-5, 5)]);
             * unitFactory.Create(1, UnitBaseType.Simple, WeaponType.Shield, GetComponent<ScenarioLoader>().HexGrid[new Vector2(-3, 5)]);
             * unitFactory.Create(2, UnitBaseType.Simple, WeaponType.Spear, GetComponent<ScenarioLoader>().HexGrid[new Vector2(0, -5)]);
             * unitFactory.Create(2, UnitBaseType.Simple, WeaponType.Flail, GetComponent<ScenarioLoader>().HexGrid[new Vector2(-3, -5)]);*/
            {
            }

            // Initialize the first turn
            selectionManager.Initialize();

            if (tutorialManager != null)
            {
                tutorialManager.Initialize();
            }
        }