コード例 #1
0
        public void Attack(IntVector2 position)
        {
            _targetUnit = _occupatedPossitionsMap.GetUnitOnPosition(position);
            if (_targetUnit is UnitStub)
            {
                return;
            }

            _targetUnit = _occupatedPossitionsMap.GetUnitOnPosition(position);
            _targetOvertaker.OvertakeComplete += OvertakeTargetHandler;
            _targetOvertaker.Overtake(_targetUnit);
        }
コード例 #2
0
        public override void Attack(IntVector2 position)
        {
            var targetUnit = _occupatedPossitionsMap.GetUnitOnPosition(position);

            if (targetUnit is UnitStub)
            {
                return;
            }

            _agressiveBehaviour.Complete += AcctackCompleteHandler;
            _agressiveBehaviour.Start(targetUnit);
        }
コード例 #3
0
        private void WaitUnitOnPosition(IntVector2 position)
        {
            _targetUnit = _occupatedPossitionsMap.GetUnitOnPosition(position);
            if (Equals(_targetUnit.DynamicInfo.WaitPosition, _baseActionController.Position))
            {
                IntVector2 newPosition = _movingRandomizer.GetRandomPoint(_baseActionController.Position);
                _baseActionController.MoveToPosition(newPosition);
                return;
            }

            _baseActionController.WaitPosition(_targetUnit.Position);
            _unitInfo.SetWaitPosition(position);
            _targetUnit.UnitEvents.PositionChanged += TargetUnitPositionChanged;
        }
コード例 #4
0
        private List <IOneUnitController> GetUnitsInRange(IntVector2 position)
        {
            var unitsInRange  = new List <IOneUnitController>();
            var pointsInRange = GetPointsInRange(position);

            pointsInRange.ForEach(p =>
            {
                var unit = _occupatedPossitionsMap.GetUnitOnPosition(p);
                if (!(unit is UnitStub) && !unit.Position.Equals(_baseActionController.Position))
                {
                    unitsInRange.Add(unit);
                }
            });

            return(unitsInRange);
        }
コード例 #5
0
        public static List <IOneUnitController> GetUnitsInRegion(this IOccupatedPossitionsMap possitionsMap,
                                                                 IntVector2 point1, IntVector2 point2)
        {
            var units       = new List <IOneUnitController>();
            var loopParamsI = new LoopPaprams(point1.x, point2.x);

            for (int i = loopParamsI.StartValue; loopParamsI.Condition(i); i = loopParamsI.Operation(i))
            {
                var loopParamsJ = new LoopPaprams(point1.y, point2.y);
                for (int j = loopParamsJ.StartValue; loopParamsJ.Condition(j); j = loopParamsJ.Operation(j))
                {
                    if (!possitionsMap.IsVacantPosition(new IntVector2(i, j)))
                    {
                        units.Add(possitionsMap.GetUnitOnPosition(new IntVector2(i, j)));
                    }
                }
            }

            return(units);
        }
コード例 #6
0
        public void GenerateEnemy()
        {
START:
            var point = GetRandomPoint();

            if (!_grid.GetCell(point))
            {
                goto START;
            }
            if (_occupatedPossitionsMap.GetUnitOnPosition(point) is UnitStub)
            {
                var enemy = _enemyFactory.Invoke();
                enemy.SetOnPosition(point);
                enemy.UnitEvents.HealthEnded += HealthEndedHandler;
                //enemy.Attack(_player.Position);
                //enemy.AttackComplete += AttackCompleteHandler;

                /*
                 * var un = GetRUn(enemy.Position);
                 * if (un == null)
                 * {
                 *  enemy.Animate();
                 * }
                 * else
                 * {
                 *  enemy.Attack(un);
                 * }
                 *
                 * void AttackCompleteHandler()
                 * {
                 *  enemy.Attack(GetRUn(enemy.Position));
                 * }*/
            }
            else
            {
                goto START;
            }
        }
コード例 #7
0
 public void ApplyDamageOnPosition(IntVector2 position)
 {
     _targetUnit = _occupatedPossitionsMap.GetUnitOnPosition(position);
     _targetUnit.TakeDamage(_unitSettings.Attack);
 }