コード例 #1
0
    // Update is called once per frame
    public override void Update()
    {
        //..and not a server-controlled object
        if (!unit.netID.isServer)
        {
            return;
        }

        if (!tower.flags.is_dead)
        {
            ThinkTimer.update_timer();
            if (ThinkTimer.is_over())
            {
                clean_up_all_lists();
                think();
                ThinkTimer.restart();
            }

            //if we're aiming at a target, move until within range, and attack
            if (unit.cur_target_obj != null)
            {
                if (unit.within_range(unit.cur_target_obj))
                {
                    unit.auto_attack(unit.cur_target_obj);
                }
            }
            else                //continue with the objective
            {
                unit.flags.in_combat = false;
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    public override void Update()
    {
        if (!champ.netID.isLocalPlayer)
        {
            return;
        }

        if ((!unit.flags.is_dead) && champ.ai_takeover)
        {
            ThinkTimer.update_timer();
            if (ThinkTimer.is_over())
            {
                clean_up_all_lists();
                think();
                ThinkTimer.restart();
            }

            //this is "HOLD"
            //if we're aiming at a target, move until within range, and attack
            if (unit.cur_target_obj != null)
            {
                if ((Utility.LayerTargetable(unit.cur_target_obj)) &&
                    Utility.get_dist_position(holdedPos, unit.cur_target_obj.transform.position) <= GameSceneConsts.ai_max_chase_range)
                {
                    if (unit.within_range(unit.cur_target_obj))
                    {
                        unit.stop_moving();
                        //unit.auto_attack (unit.cur_target_obj);
                    }
                    else                        //we have to move close to the target
                    {
                        unit.resume_moving();
                        unit.attackto(unit.cur_target_obj);
                    }
                }
                else
                {
                    unit.resume_moving();
                    unit.cur_target_obj = null;
                }
            }
            else                //continue with the objective
            {
                unit.resume_moving();
                if (Utility.get_dist_position(holdedPos, champ.transform.position) >= 0.25f)
                {
                    champ.moveto(holdedPos);
                }
            }
        }
        else if (!unit.flags.is_dead)
        {
            unit.resume_moving();
            holdedPos = champ.transform.position;
        }
        else if (unit.flags.is_dead)
        {
            if (unit.fac == Types.Faction.BLUE)
            {
                holdedPos = GameSceneConsts.blue_team_respawn_pt.transform.position;
            }
            else if (unit.fac == Types.Faction.RED)
            {
                holdedPos = GameSceneConsts.blue_team_respawn_pt.transform.position;
            }
        }
    }