예제 #1
0
 public void AttackEnd()
 {
     //Debug.Log("AttackEnd");
     //CharacterInfo attackCharInfo = soliderInfo.GetTargetInfo();
     //如果目标死亡,回归空闲状态
     if (attackInfo == null || attackInfo.IsDead())
     {
         soliderInfo.ChangeState("idle");
     }
     //如果目标未死亡,继续攻击状态
     else
     {
         //Debug.Log("continue attack");
         soliderInfo.ChangeState("attack", new StateParam(attackInfo));
     }
 }
예제 #2
0
 public void EnterExcute()
 {
     Debug.Log("BarrackInfo DoAction Start");
     barrackInfo.DoAction("start");
     curTime = 0;
     for (int i = 0; i < 3; i++)
     {
         //如果兵营中已存在该Index的兵种
         if (barrackInfo.ContainsSolider(i))
         {
             SoliderInfo solider = barrackInfo.GetSolider(i);
             //如果该兵种已死亡
             if (solider.IsDead())
             {
                 solider.Reset();
                 solider.ChangeState("ready");
             }
         }
         //如果兵营不存在该Index兵种
         else
         {
             SoliderInfo solider = EntityManager.getInstance().AddSolider(barrackInfo.soliderId);
             solider.SetBarrackPos(barrackInfo.soliderPos[i], barrackInfo.GetPosition());
             solider.ChangeState("ready");
             barrackInfo.AddSolider(i, solider);
         }
     }
 }
예제 #3
0
    public void AttackEnd()
    {
        //Debug.Log("SkillEnd");
        CharacterInfo attackCharInfo = soliderInfo.GetAttackInfo();

        //如果目标死亡,回归空闲状态
        if (attackCharInfo.IsDead())
        {
            attackCharInfo.ChangeState("die");
            soliderInfo.ChangeState("ready");
        }
        //如果目标未死亡,继续攻击状态
        else
        {
            //Debug.Log("continue attack");
            soliderInfo.ChangeState("attack");
        }
    }
예제 #4
0
    public void RunAI()
    {
        CharacterInfo targetInfo = soliderInfo.RunAI();

        //若未找到目标,继续空闲
        if (targetInfo == null)
        {
            soliderInfo.ChangeState("idle");
        }
        //若找到目标,目标停住,并进入移动状态
        else
        {
            //双方都输入攻击目标,均被占用,不再接受其他人的约战
            targetInfo.SetAttackInfo(soliderInfo);
            targetInfo.ChangeState("idle", soliderInfo);
            soliderInfo.SetAttackInfo(targetInfo);
            soliderInfo.ChangeState("move", targetInfo);
        }
    }
예제 #5
0
    public void RunAI()
    {
        CharacterInfo targetInfo = soliderInfo.RunAI();

        //若未找到目标,继续空闲
        if (targetInfo == null)
        {
            if (!soliderInfo.WithinStayPos())
            {
                soliderInfo.ChangeState("ready");
            }
        }
        //若找到目标,目标停住,并进入移动状态
        else
        {
            //双方都输入攻击目标,均被占用,不再接受其他人的约战
            //怪物进入等待状态,并且向目标的攻击列表中添加
            targetInfo.ChangeState("idle", new StateParam(soliderInfo));
            //兵种进入到移动状态,向targetInfo移动
            soliderInfo.ChangeState("move", new StateParam(targetInfo));
        }
    }
 public void InitSoliderDict()
 {
     Vector3 [] pos = new Vector3[4];
     pos[1] = new Vector3(signPos.x + 30, signPos.y + 40, signPos.z);
     pos[2] = new Vector3(signPos.x - 30, signPos.y + 40, signPos.z);
     pos[3] = new Vector3(signPos.x, signPos.y + 40, signPos.z);
     for (int i = 1; i <= 3; i++)
     {
         SoliderInfo solider = EntityManager.getInstance().AddSolider(50001);
         solider.SetTowerInfo(this, i, pos[i]);
         solider.ChangeState("ready");
         soliderDict.Add(i, solider);
     }
 }
예제 #7
0
    public void Excute()
    {
        Vector3 pos = soliderInfo.GetPosition();
        float   dis = BattleUtils.Distance2(pos, targetPos);

        if (dis < speed * Time.deltaTime)
        {
            soliderInfo.SetPosition(targetPos.x, targetPos.y, targetPos.z);
            soliderInfo.ChangeState("attack", new StateParam(attackInfo));
        }
        else
        {
            pos = Vector3.MoveTowards(pos, targetPos, Time.deltaTime * speed);
            soliderInfo.SetPosition(pos.x, pos.y, pos.z);
        }
    }
예제 #8
0
    public void Excute()
    {
        Vector3 pos = soliderInfo.GetPosition();
        float   dis = BattleUtils.Distance2(pos, targetPos);

        if (dis < 10 * Time.deltaTime)
        {
            soliderInfo.SetPosition(targetPos.x, targetPos.y, targetPos.z);
            soliderInfo.ChangeState("idle");
        }
        else
        {
            pos = Vector3.MoveTowards(pos, targetPos, Time.deltaTime * 10);
            soliderInfo.SetPosition(pos.x, pos.y, pos.z);
        }
    }
예제 #9
0
    public void Excute()
    {
        Vector3 pos = soliderInfo.GetPosition();
        float   dis = Vector3.Distance(pos, targetPos);

        if (dis < speed * Time.deltaTime)
        {
            soliderInfo.SetPosition(targetPos.x, targetPos.y, targetPos.z);
            CharacterInfo attackInfo = soliderInfo.GetAttackInfo();
            soliderInfo.SetAttackInfo(attackInfo);
            attackInfo.SetAttackInfo(soliderInfo);
            soliderInfo.ChangeState("attack", attackInfo);
            attackInfo.ChangeState("attack", soliderInfo);
        }
        else
        {
            pos = Vector3.MoveTowards(pos, targetPos, Time.deltaTime * speed);
            soliderInfo.SetPosition(pos.x, pos.y, pos.z);
        }
    }