Esempio n. 1
0
        protected override void DoTheLogic()
        {
            //			Debug.Log (casting + "casting is ");
            //			Debug.Log (cooldown + "casting is ");
            var targets = _world.GetEnemyUnitsTo(_unit.Alliance);

            Target = new UnitTarget(targets.GetClosestUnit1(_unit));             //make this the correct target finder


            if (CanCast(_unit) && _unit.IsAlive)                 //doesn't check for target being in range here
            {
                SetCastTick();
                Cast();
            }

            if (casting == true)
            {
                if (!_unit.IsAlive)                   //conditions to stop cast
                {
                    CastCancel();
                }
                if (CastFinalTick())
                {
                    CastCancel();
                    Execute();
                    SetCooldownTick();
                }
            }

            if (CooldownTickCheck())
            {
                CoolDownCancel();
            }
        }
        protected override void DoTheLogic()
        {
//			Debug.Log (casting + "casting is ");
//			Debug.Log (cooldown + "casting is ");
            var targets = _world.GetEnemyUnitsTo(_unit.Alliance);

            Target = new UnitTarget(targets.GetClosestUnit1(_unit));             //make this the correct target finder


            if (CanCast(_unit) && _unit.IsAlive && Target != null && _unit.Position.IsInRange(Target.GetPosition(), _data.AbilityRange))
            {
                SetCastTick();
                Cast();
            }

            if (casting == true)
            {
                if (!_unit.IsAlive)                   //conditions to stop cast
                {
                    CastCancel();
                }
                if (CastFinalTick())
                {
                    CastCancel();
                    Execute();
                    SetCooldownTick();
                }
            }

            if (CooldownTickCheck())
            {
                CoolDownCancel();
            }
        }
Esempio n. 3
0
    public void Ready(SpawnPointScript spawnPoint, PlayerScript player, Unit unit)
    {
        _targetingData    = new UnitTarget();
        _hoveredState     = HoveredState.NotHovered;
        _unitAction       = UnitAction.Idle;
        _unit             = unit;
        _playerScript     = player;
        _spawnPointScript = spawnPoint;

        transform.localPosition = Vector3.zero;
        _unitSprite.flipX       = !_playerScript.IsMe;
        _spawnPointScript.SetOccupied();

        _selectorArrows = new GameObject[_arrowInstanceCount];

        for (int i = 0; i < _arrowInstanceCount; i++)
        {
            _selectorArrows[i] = Instantiate(_selectorArrow, transform);
            _selectorArrows[i].GetComponentInChildren <SpriteRenderer>().enabled = false;
            if (i != _arrowInstanceCount - 1)
            {
                _selectorArrows[i].transform.localScale *= 0.7f;
            }
        }

        _sleepEffect.SetActive(true);
        UpdateTexts();
        ReadyEvents();
    }
Esempio n. 4
0
    public void StartTargeting(UnitTarget targetData)
    {
        if (_unitAction != UnitAction.Idle)
        {
            return;
        }

        _targetingData = targetData;

        _unitAction = UnitAction.Targeting;

        for (int i = 0; i < _arrowInstanceCount; i++)
        {
            _selectorArrows[i].GetComponentInChildren <SpriteRenderer>().enabled = true;
        }
        Cursor.visible = false;
    }
        protected override void DoTheLogic()
        {
            var targets = _world.GetAllyUnitsTo(_unit.Alliance);

            _target = new UnitTarget(targets.GetClosestUnit1(_unit));

            if (_target != null && !_target.UnitModel.IsAlive && !_target.UnitModel.IsReviving)
            {
                instaResurrect();
            }

            //here the logic for if to check for ability cast
            //first checks if no other abilities are being cast
            if (!_unit.AnyAbilitiesCasting() && !cooldown && _unit.IsAlive && _unit.Position.IsInRange(_target.GetPosition(), _data.abilityRange))
            {
                Cast();
                Debug.Log("this should only be called once");
            }

            //here the logic for the ability cast

            //here the logic for if it is casting, does it continue to cast
            if (casting == true)
            {
                if (!_unit.IsAlive)
                {
                    castFinalTick = -1;
                    casting       = false;
                }
                if (_tickService.currentTick > castFinalTick)
                {
                    casting       = false;
                    castFinalTick = -1;
                    Execute();                                                                                                          ///i put all the logic in execute, This is best I think.
                    cooldownFinalTick = _tickService.currentTick + (int)(_data.cooldownTime / _tickService.tickTime);
                    cooldown          = true;
                }
            }
            //careful with the is eqaul to and equals
            if (cooldown == true && _tickService.currentTick > cooldownFinalTick)
            {
                cooldownFinalTick = -1;
                cooldown          = false;
            }
        }
Esempio n. 6
0
    public void StartAttackTargetSelect()
    {
        if (!_playerScript.IsMe || !_playerScript.Player.IsMyTurn)
        {
            return;
        }
        if (_unit.State == UnitState.GettingReady)
        {
            return;
        }

        UnitTarget unitTarget = new UnitTarget();

        unitTarget.onComplete = (selectedUnit) =>
        {
            _unit.Owner.RequestCommandAttack(_unit, selectedUnit.Unit);
        };

        unitTarget.onInvalidTarget = (invalidTarget) =>
        {
            Debug.Log("Invalid target!");
        };

        unitTarget.validator = (unit) =>
        {
            return(unit.Owner != _playerScript.Player && unit.State != UnitState.Dead);
        };

        unitTarget.onValidTargetMouseEnter = (unit) =>
        {
            unit.SetDeathMarkerActive(unit.Unit.Health - _unit.Damage <= 0);
            SetDeathMarkerActive(_unit.Health - unit.Unit.Damage <= 0);
        };

        unitTarget.onValidTargetMouseExit = (unit) =>
        {
            unit.SetDeathMarkerActive(false);
            SetDeathMarkerActive(false);
        };

        unitTarget.currentTarget = null;

        StartTargeting(unitTarget);
    }
Esempio n. 7
0
        protected override void DoTheLogic()
        {
            if (damageDone > damageDoneUpgradeRequirement)
            {
                var targets = _world.GetAllyUnitsTo(_unit.Alliance);
                _target = new UnitTarget(targets.GetClosestUnit1(_unit));
            }

            //here the logic for if to check for ability cast
            //first checks if no other abilities are being cast
            if (_target != null && !_unit.AnyAbilitiesCasting() && !cooldown && _unit.IsAlive && _unit.Position.IsInRange(_target.GetPosition(), _data.abilityRange))
            {
                Cast();
            }

            //here the logic for the ability cast

            //here the logic for if it is casting, does it continue to cast
            if (casting == true)
            {
                if (!_unit.IsAlive)
                {
                    castFinalTick = -1;
                    casting       = false;
                }
                if (_tickService.currentTick > castFinalTick)
                {
                    casting       = false;
                    castFinalTick = -1;
                    Execute();                                                                                                          ///i put all the logic in execute, This is best I think.
                    cooldownFinalTick = _tickService.currentTick + _data.cooldownTick;
                    cooldown          = true;
                }
            }
            //careful with the is eqaul to and equals
            if (cooldown == true && _tickService.currentTick > cooldownFinalTick)
            {
                cooldownFinalTick = -1;
                cooldown          = false;
            }
        }
        protected override void DoTheLogic()
        {
            var targets = _world.GetEnemyUnitsTo(_unit.Alliance);

            _target = new UnitTarget(targets.GetClosestUnit1(_unit));
        }