Example #1
0
        private IEnumerator DeathAnimation(UnitSpriteManager spriteManager)
        {
            spriteManager.ShowExtraInfo(UnitSpriteManager.UnitInfoDisplaySource.Death, false);
            spriteManager.FlashFade(Color.white);

            yield return(new WaitForSeconds(Config.flashFadeDestroyTimer));

            spriteManager.ShowExtraInfo(UnitSpriteManager.UnitInfoDisplaySource.Death, false);
            spriteManager.DisableUnit();

            deathAnimation = null;
        }
        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;
        }
Example #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);
        }
Example #4
0
 public void AnimateDeath(UnitSpriteManager spriteManager)
 {
     deathAnimation = selectionManager.StartCoroutine(DeathAnimation(spriteManager));
 }
Example #5
0
        // Ranged Attack Animation
        public void ShootArrow(UnitSpriteManager target)
        {
            GameObject arrow = (GameObject)Instantiate(animationArrowPrefab, transform.position, Quaternion.identity);

            arrow.GetComponent <ShotController>().target = target;
        }
Example #6
0
 // Bump attack animation
 public void Bump(UnitSpriteManager target)
 {
     startBumpTime = Time.unscaledTime;
     bumpTarget    = target;
     bumping       = true;
 }