Exemplo n.º 1
0
 public WSUnitDescriptor(SZWSUnitDescriptor toCopy)
 {
     position   = new Vector2(toCopy.positionX, toCopy.positionY);
     unitType   = toCopy.unitType;
     weaponType = toCopy.weaponType;
     player     = toCopy.player;
 }
Exemplo n.º 2
0
 public WSUnitDescriptor(Vector2 position, UnitBaseType unitType, WeaponType weaponType, int player)
 {
     this.position   = position;
     this.unitType   = unitType;
     this.weaponType = weaponType;
     this.player     = player;
 }
Exemplo n.º 3
0
        public void MenuOptionClicked(UnitOrWeapon optionType, UnitBaseType unitType, WeaponType weapon)
        {
            MenuOptionEndHover();

            if (optionType == UnitOrWeapon.Unit)
            {
                _units[activePlayer][SelectedUnitIter].UnitType = unitType;
                SelectedUnitIter++;
            }
            if (optionType == UnitOrWeapon.Weapon)
            {
                _units[activePlayer][SelectedUnitIter].WeaponType = weapon;

                bool foundEmpty = false;

                /*
                 * for (int i = 0; i < _units[turn].Count; i++) {
                 *  if (_units[turn][i].WeaponType == WeaponType.None) {
                 *      SelectedUnitIter = i;
                 *      foundEmpty = true;
                 *      break;
                 *  }
                 * }*/
                if (!foundEmpty)
                {
                    SelectedUnitIter++;
                }
            }
        }
Exemplo n.º 4
0
 public SZWSUnitDescriptor(WSUnitDescriptor toCopy)
 {
     positionX  = toCopy.position.x;
     positionY  = toCopy.position.y;
     unitType   = toCopy.unitType;
     weaponType = toCopy.weaponType;
     player     = toCopy.player;
 }
Exemplo n.º 5
0
 public void MenuOptionHover(UnitOrWeapon optiontype, UnitBaseType unitType, WeaponType weaponType)
 {
     hoverStartTime    = Time.time;
     amHovering        = true;
     hoveredOptionType = optiontype;
     hoveredBaseType   = unitType;
     hoveredWeaponType = weaponType;
 }
Exemplo n.º 6
0
 public void UnitGhostReleased(WSUnitManager unit)
 {
     if (_hoveredUnit == null)
     {
         unit.EnableUnitVisual();
     }
     else
     {
         UnitBaseType tempUnit   = unit.UnitType;
         WeaponType   tempWeapon = unit.WeaponType;
         unit.UnitType           = _hoveredUnit.UnitType;
         unit.WeaponType         = _hoveredUnit.WeaponType;
         _hoveredUnit.UnitType   = tempUnit;
         _hoveredUnit.WeaponType = tempWeapon;
         unit.EnableUnitVisual();
     }
 }
Exemplo n.º 7
0
        public void OptionGhostReleased(UnitOrWeapon optionType, UnitBaseType unitType, WeaponType weapon)
        {
            if (_hoveredUnit != null)
            {
                if (_units[activePlayer][SelectedUnitIter] == _hoveredUnit)
                {
                    SelectedUnitIter++;
                }

                if (optionType == UnitOrWeapon.Unit)
                {
                    _hoveredUnit.UnitType = unitType;
                }
                else if (optionType == UnitOrWeapon.Weapon)
                {
                    _hoveredUnit.WeaponType = weapon;
                }
            }
        }
Exemplo n.º 8
0
        private static bool MeetsTerrainCostRequirement(List <HexEntry> path, IUnitController controller, int movesRemaining)
        {
            int          sum      = 0;
            UnitBaseType unitType = controller.UnitType;

            // Note: skip the origin of the path
            foreach (HexEntry hex in path.Skip(1))
            {
                if (UnitBaseStats.TerrainCost(unitType, hex.Terrain) <= 0)
                {
                    return(false);
                }
                if (hex.Occupant != null)
                {
                    return(false);
                }
                sum += UnitBaseStats.TerrainCost(unitType, hex.Terrain);
            }
            return(sum <= movesRemaining);
        }
Exemplo n.º 9
0
 public static int TerrainCost(UnitBaseType unitType, Terrain terrain)
 {
     return(Stats[(int)unitType, (int)terrain + (int)StatOrder.Normal]);
 }
Exemplo n.º 10
0
 public static int Damage(UnitBaseType unitType, WeaponType weapon)
 {
     return(Stats[(int)unitType, (int)weapon - 1 + (int)StatOrder.Spear]);
 }
Exemplo n.º 11
0
 public static int HP(UnitBaseType unitType)
 {
     return(Stats[(int)unitType, (int)StatOrder.HP]);
 }
Exemplo n.º 12
0
 public static int MoveSpeed(UnitBaseType unitType)
 {
     return(Stats[(int)unitType, (int)StatOrder.MoveSpeed]);
 }
Exemplo n.º 13
0
        //</Stats>

        public DefaultUnitController(UnitBaseType unitType, WeaponType weaponType, int playerOwner)
        {
            this._unitType    = unitType;
            this._weaponType  = weaponType;
            this._playerOwner = playerOwner;
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        // Lower is better
        private int HexSpacingWeight(UnitBaseType unitType, WeaponType weaponType, HexEntry hex)
        {
            int result = 0;

            // Per-weapon spacing weights
            if (weaponType == WeaponType.Spear)
            {
                if (hex.AIDistanceToEnemy == 1)
                {
                    result = +2;
                }
                if (hex.AIDistanceToEnemy == UnitBaseStats.MoveSpeed(unitType) + 1)
                {
                    result = -2;
                }
            }
            if (weaponType == WeaponType.Sword)
            {
                if (hex.AIDistanceToEnemy == 1)
                {
                    result = -1;
                }
                if (hex.AIDistanceToEnemy == 2)
                {
                    result = +1;
                }
                if (hex.AIDistanceToEnemy == UnitBaseStats.MoveSpeed(unitType) + 1)
                {
                    result = +2;
                }
            }
            if (weaponType == WeaponType.Flail)
            {
                result = -1 * hex.aiAdjacentEnemies;
            }
            if (weaponType == WeaponType.Longbow)
            {
                if (hex.AIDistanceToEnemy == 2)
                {
                    result = -4;
                }
                if (hex.AIDistanceToEnemy == 3)
                {
                    result = -8;
                }
            }
            if (weaponType == WeaponType.Dagger)
            {
                result = -2 * hex.aiAdjacentEnemies;
            }
            if (weaponType == WeaponType.Shield)
            {
                if (hex.AIDistanceToEnemy == 1)
                {
                    result = +3;
                }
            }

            //Generally encourage movement toward the enemy if out of range
            if (hex.AIDistanceToEnemy > UnitBaseStats.MoveSpeed(unitType) + 1)
            {
                result += hex.AIDistanceToEnemy - UnitBaseStats.MoveSpeed(unitType) - 1;
            }

            return(result);
        }