示例#1
0
    public static Cmd_Attack New(GameObject prGameObject, GameObject prTargetUnit)
    {
        Cmd_Attack newCommand = prGameObject.AddComponent <Cmd_Attack>();

        newCommand.TargetUnit = prTargetUnit;

        return(newCommand);
    }
示例#2
0
 void FindAndAttack()
 {
     currentTarget = FindTarget();
     if (currentTarget != null)
     {
         commandManager.InsertCommand(Cmd_Attack.New(transform.gameObject, currentTarget.gameObject, 25));
     }
 }
示例#3
0
    public static Cmd_Attack New(GameObject prGameObject, GameObject prTargetUnit, float prLeashDistance, Vector3 prStartingLocation)
    {
        Cmd_Attack newCommand = prGameObject.AddComponent <Cmd_Attack>();

        newCommand.TargetUnit    = prTargetUnit;
        newCommand.leashDistance = prLeashDistance;
        newCommand.startingPoint = prStartingLocation;
        return(newCommand);
    }
示例#4
0
    public static Cmd_Attack New(GameObject prGameObject, GameObject prTargetUnit, float prLeashDistance)
    {
        Cmd_Attack newCommand = prGameObject.AddComponent <Cmd_Attack>();

        newCommand.TargetUnit    = prTargetUnit;
        newCommand.leashDistance = prLeashDistance;

        return(newCommand);
    }
示例#5
0
 public override void RightClickOnUnit(GameObject TargetUnit)
 {
     if (TargetUnit.GetComponent <Player>().Info.Name == GetComponent <Player>().Info.Name)
     {
         commandManager.AddCommand(Cmd_Follow.New(transform.gameObject, TargetUnit));
     }
     else
     {
         commandManager.AddCommand(Cmd_Attack.New(transform.gameObject, TargetUnit));
     }
 }
示例#6
0
 public override void RightClickOnStructure(GameObject TargetUnit)
 {
     if (TargetUnit.GetComponent <StockManager>() != null)
     {
         commandManager.AddCommand(Cmd_humanEquip.New(gameObject, TargetUnit));
         return;
     }
     if (TargetUnit.GetComponent <Player>().Info.Name == GetComponent <Player>().Info.Name)
     {
         commandManager.AddCommand(Cmd_Move.New(transform.gameObject, TargetUnit.transform.position));
     }
     else
     {
         commandManager.AddCommand(Cmd_Attack.New(transform.gameObject, TargetUnit));
     }
 }
示例#7
0
    private void AttackWithAllUnits()
    {
        var destination = (Vector3)RtsManager.Current.ScreenPointToMapPosition(Input.mousePosition);

        if (Utilities.CheckMouseHit() != null)
        {
            var hit = (RaycastHit)Utilities.CheckMouseHit();
            foreach (var Unit in MouseManager.Current.Selections)
            {
                if (Unit.GetComponent <UnitInfo>().unitType == "Structure")
                {
                    continue;
                }

                switch (hit.transform.gameObject.tag)
                {
                case "Structure":
                    Unit.GetComponent <CommandManager>().AddCommand(Cmd_Attack.New(Unit.gameObject, hit.transform.gameObject));
                    break;

                case "Unit":
                    Unit.GetComponent <CommandManager>().AddCommand(Cmd_Attack.New(Unit.gameObject, hit.transform.gameObject));
                    break;

                case "Gold":
                    Debug.Log("itsAMine");
                    Unit.GetComponent <CommandManager>().AddCommand(Cmd_Move.New(Unit.gameObject, destination, true));
                    break;

                default:
                    Unit.GetComponent <CommandManager>().AddCommand(Cmd_Move.New(Unit.gameObject, destination, true));
                    break;
                }
            }
        }
    }