// 普通攻击
    private void PlayAttack()
    {
        if (Owner.TargetAttacking == null || Owner.TargetAttacking.IsDead)
        {
            Owner.Idle();
            return;
        }

        _hasAttack       = false;
        _hasAttackFinish = false;
        _startAttackTime = BattleTime.GetTime();

        if (Owner.Cfg.TurnToTarget > 0)
        {
            // 攻击时转向目标
            Owner.TurnToTarget(Owner.TargetAttacking.Position);
        }

        if (!string.IsNullOrEmpty(Owner.AtkAnimation))
        {
            Owner.PlayAnimation(Owner.AtkAnimation);
            // TODO:播放攻击特效
            Owner.CallFunction("OnAttackPreview");
        }
    }
 public override void OnTick()
 {
     if (!_hasAttack)
     {
         // 攻击前摇时间到,出现弹道
         if (BattleTime.GetTime() - _startAttackTime >= Owner.GetAtkHitpoint())
         {
             LaunchProjectile();
             _hasAttack = true;
         }
     }
     else
     {
         // 大于攻击间隔
         if (BattleTime.GetTime() - _startAttackTime >= Owner.GetAtkInterval())
         {
             PlayAttack();
         }
         else
         {
             if (!_hasAttackFinish)
             {
                 // 如果当前动作播放完毕,则播放待机动作
                 if (Owner.IsCurrentAnimationFinish())
                 {
                     _hasAttackFinish = true;
                     Owner.PlayAnimation(AnimationName.Idle);
                 }
             }
         }
     }
 }
Beispiel #3
0
    // 添加 buff 或者光环
    public void AddBuff(string buffName, int duration, Skill skill, bool isStack = false)
    {
        if (string.IsNullOrEmpty(buffName))
        {
            return;
        }

        // buff 不能叠加则返回
        if (!isStack)
        {
            foreach (var item in _buffList)
            {
                if (item.Name == buffName)
                {
                    return;
                }
            }
        }
        Buff buff = new Buff();

        buff.Name       = buffName;
        buff.Script     = buffName;
        buff.Owner      = this;
        buff.Skill      = skill;
        buff.CreateTime = BattleTime.GetTime();
        buff.Duration   = duration;
        buff.RemainTime = duration;
        _buffList.Add(buff);
        buff.OnCreate();
        // 更新玩家属性
        UpdateProperty();
    }
Beispiel #4
0
    // 开始播放技能
    public void Play()
    {
        _startTime = BattleTime.GetTime();
        _state     = State.PHASE_START;

        // 通知脚本
        CallFunction("OnSpellStart");
    }
Beispiel #5
0
    // 每帧思考
    private void OnThink()
    {
        if (_thinkInterval <= 0)
        {
            return;
        }

        if (BattleTime.GetTime() - _lastThinkTime >= _thinkInterval)
        {
            _lastThinkTime = BattleTime.GetTime();
            CallFunction("OnThink");
        }
    }
Beispiel #6
0
 // 搜索敌人,单位在移动的时候也会搜索新的攻击目标,直到开始攻击
 private void ScanTarget()
 {
     if (BattleTime.GetTime() - _lastScanTime > 1000)
     {
         _lastScanTime = BattleTime.GetTime();
         Actor target = Owner.ScanTarget();
         if (target != null)
         {
             // 新的目标或者新的路径 TODO 将来进行优化如果路径没有改变则不需要重新寻路
             _currentMoveToPos = target.Position;
             SearchPath();
         }
     }
 }
Beispiel #7
0
 static int GetTimestamp(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         int o = BattleTime.GetTimestamp();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #8
0
    // 处理每帧的回调
    private void ProcessThink()
    {
        if (_intervalTime <= 0)
        {
            return;
        }

        // 间隔触发的事件
        if (_intervalTime > 0 && BattleTime.GetTime() - _lastThinkTime >= _intervalTime)
        {
            // 通知脚本
            CallFunction("OnThink");
            _lastThinkTime = BattleTime.GetTime();
        }
    }
Beispiel #9
0
 private void ScanTarget()
 {
     if (BattleTime.GetTime() - _lastScanTime > 1000)
     {
         _lastScanTime = BattleTime.GetTime();
         Actor target = Owner.ScanTarget();
         if (target != null)
         {
             if (Owner.IsBuilding())
             {
                 Owner.PlayAttack(target);
             }
             else
             {
                 Owner.MoveToTarget(target);
             }
         }
     }
 }
Beispiel #10
0
    // 每逻辑帧更新
    public void OnTick()
    {
        if (BattleTime.GetTime() - _startTime > Duration)
        {
            // 技能结束
            _state = State.NOT_START;

            OnDestory();

            // 通知上层逻辑技能结束
            if (OnSkillFinish != null)
            {
                OnSkillFinish(this);
            }

            return;
        }

        ProcessThink();
    }
Beispiel #11
0
    static int _CreateBattleTime(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                BattleTime obj = new BattleTime();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: BattleTime.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #12
0
 // 逻辑帧更新(100ms)
 public override void OnTick()
 {
     if (!_applyHurt)
     {
         // 攻击前摇
         if (BattleTime.GetTime() - _startAttackTime >= Owner.GetAtkHitpoint())
         {
             _applyHurt = true;
             if (Owner.TargetAttacking != null)
             {
                 // 前摇结束,造成伤害
                 Owner.TargetAttacking.OnHit(Owner.GetDamage());
                 // TODO:这里仅迁就王子冲锋首次攻击会有伤害加成,以后需要修改更加通用框架
                 Owner.CallFunction("OnAfterAttack");
             }
         }
     }
     else
     {
         if (BattleTime.GetTime() - _startAttackTime >= Owner.GetAtkInterval())
         {
             PlayAttack();
         }
         //下一轮攻击时间未到
         else
         {
             //if (!_hasAttackFinish)
             //{
             //    // 如果当前动作播放完毕,则播放待机动作
             //    if (Owner.IsCurrentAnimationFinish())
             //    {
             //        _hasAttackFinish = true;
             //        Owner.PlayAnimation(AnimationName.Idle);
             //    }
             //}
         }
     }
 }
Beispiel #13
0
    // 刷新倒计时
    private void OnRefreshTime()
    {
        int time      = 0;
        int timestamp = BattleTime.GetTimestamp();

        _txtOverTimeText.gameObject.SetActive(false);
        if (timestamp > GameConfig.GAME_TIME + GameConfig.OVER_TIME)
        {
            // 比赛结束
            time = GameConfig.GAME_TIME + GameConfig.OVER_TIME - timestamp;
        }
        else if (timestamp > GameConfig.GAME_TIME)
        {
            // 加时赛时间
            time = GameConfig.GAME_TIME + GameConfig.OVER_TIME - timestamp;
            _txtOverTimeText.gameObject.SetActive(true);
        }
        else if (timestamp > GameConfig.GAME_TIME - GameConfig.DOUBLE_TIME)
        {
            // 双倍圣水时间
            time = GameConfig.GAME_TIME - timestamp;
        }
        else
        {
            // 正常时间
            time = GameConfig.GAME_TIME - timestamp;
        }

        _txtTime.text = Utils.GetCountDownTime(time / 1000f);

        // _txtOverTimeText  如果是加时赛,则显示这个文本

        // 圣水量显示为0-10
        _txtMP.text = (BattleController.Instance.Mana / GameConfig.MANA_MUL).ToString();

        _imgMP.fillAmount = 1f * BattleController.Instance.Mana / GameConfig.MANA_MAX;
    }
Beispiel #14
0
 static void Main(string[] args)
 {
     BattleTime.battle();
 }
Beispiel #15
0
 void Start()
 {
     _battleTime = _displayFacade.BattleTime;
     _text.text  = "Time Limit:" + _battleTime.CurrentTime.ToString("F0");
 }