예제 #1
0
        public SZAttackResult(SelectionManager selectionManager, ScenarioLoader scenarioLoader, AttackResult toCopy)
        {
            target          = selectionManager.GetIDByUnit(toCopy.target);
            source          = selectionManager.GetIDByUnit(toCopy.source);
            healthRemaining = toCopy.healthRemaining;
            sourceHex       = scenarioLoader.GetIDByHex(toCopy.sourceHex);
            targetHex       = scenarioLoader.GetIDByHex(toCopy.targetHex);
            attackType      = toCopy.attackType;


            if (toCopy.pushMoves == null)
            {
                pushMoves = null;
            }
            else
            {
                pushMoves = new List <SZOutcome>();
                foreach (Outcome outcome in toCopy.pushMoves)
                {
                    pushMoves.Add(new SZOutcome(selectionManager, scenarioLoader, outcome));
                }
            }
        }
예제 #2
0
파일: Axe.cs 프로젝트: GBudee/deft-Sample
 public Axe(IUnitController unitController, GameManager gameManager, ScenarioLoader scenarioLoader, SelectionManager selectionManager) : base(unitController, gameManager, scenarioLoader, selectionManager)
 {
 }
예제 #3
0
        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);
        }
예제 #4
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();
            }
        }
예제 #5
0
 public EmptyWeapon(IUnitController unitController, GameManager gameManager, ScenarioLoader scenarioLoader, SelectionManager selectionManager)
 {
     this.unitController   = unitController;
     this.gameManager      = gameManager;
     this.scenarioLoader   = scenarioLoader;
     this.selectionManager = selectionManager;
 }
예제 #6
0
 public OutcomeExecutor(SelectionManager selectionManager)
 {
     this.selectionManager = selectionManager;
 }