Exemple #1
0
        private void GoToSpawnPoint(Unit.Unit UnitToCommand)
        {
            UnitToCommand.GetComponent <NavMeshAgent>().Warp(UnitToCommand.transform.position);

            if (!target)
            {
                UnitToCommand.MoveToPosition(destinationMarker.transform.position.With(y: transform.position.y));
            }
            else
            {
                UnitToCommand.OnTarget(target.GetComponent <ISelectable>());
            }
        }
        public override void OnEquip(Unit.Unit unit, InventoryKey weaponKey)
        {
            base.OnEquip(unit, weaponKey);
            _weaponKey = weaponKey;

            if (initialAmmunition != null)
            {
                var inventory = unit.GetComponent <IProvider <Inventory> >()?.Get();

                if (inventory != null)
                {
                    initialAmmunition.AddToInventory(inventory);
                }
            }
        }
Exemple #3
0
        public void StartAction(Unit.Unit unit)
        {
            var move = _unit.GetComponent <MoveAlongPath>();

            if (move == null)
            {
                _isFinished = true;
                return;
            }


            move.Move(_unit, _destination, () =>
            {
                _unit.Occupant.UpdateGrid(_unit.transform.position);
                _isFinished = true;
            }, _twoWayCollisions, _transformToMove);
        }
Exemple #4
0
        private void Attack()
        {
            if (enemy == null)
            {
                return;
            }

            time += Time.deltaTime;

            if (time >= attackSpeed)
            {
                SpawnArrow();

                enemy.GetComponent <IHealth>().ModifyHealth(damage, building);

                time = 0;
            }
        }
Exemple #5
0
        // This is a temporary solution because if i use unity animation event, it has issue with the go reference
        // I have no damn idea :((
        private IEnumerator OpponentUnitImpact(Unit.Unit originUnit, Unit.Unit opponentUnit, float time)
        {
            yield return(new WaitForSeconds(time));

            // The magic number is temporary, will implement skillset if there's enough time
            opponentUnit.GetComponent <Health.Health>().GetDamaged(1);
            opponentUnit.GetComponentInChildren <UnitMotion>().GetDamageMotion();

            if (!hasOpponentInitiatedCounter)
            {
                hasOpponentInitiatedCounter = true;
                yield return(new WaitForSeconds(time));

                Attack(opponentUnit, originUnit);
            }
            else
            {
                UnitStateManager.currentState = State.Done;
                hasOpponentInitiatedCounter   = false;
            }
        }