コード例 #1
0
ファイル: BasicTactic.cs プロジェクト: Aimoux/QFramework
    // public override void OnStart()
    // {
    //     //把移动st移除,改用行为树前置task的方式实现(比较聪明的AI,可直接在树中去掉此节点)
    //     //生成移动\等待类行动指令时,可灵活设置其帧数?
    // }

    public override TaskStatus OnUpdate()
    {
        //if not idle return;
        // target = role.defaultfindtarget by hatred\dist\?
        //null target -> Move To target task- >Use assault node

        Assault ast = sdself.Value.SelectAssault();

        if (ast == null)
        {
            return(TaskStatus.Failure);
        }
        else
        {
            return(TaskStatus.Success);
        }

        // if(!sdself.Value.OnTactic)
        // {
        //  int rand = Random.Range(0, sdself.Value.CurWeapon.ComboLists.Count);
        //  foreach(int st in sdself.Value.CurWeapon.ComboLists[rand])
        //  {
        //      sdself.Value.PushState(st);
        //  }
        // }
        // return TaskStatus.Success;
    }
コード例 #2
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings)
        {
            builder.AppendKeywordLine("modes");
            builder.AppendLine("{");
            builder.Indent();

            if (All != null)
            {
                builder.AppendKeywordLine("General");
                builder.AppendLine("{");
                builder.Indent();
                All.ToWorkshop(builder, allSettings);
                builder.Unindent();
                builder.AppendLine("}");
            }

            Assault?.ToWorkshop(builder, allSettings, "Assault");
            CaptureTheFlag?.ToWorkshop(builder, allSettings, "CaptureTheFlag");
            Control?.ToWorkshop(builder, allSettings, "Control");
            Deathmatch?.ToWorkshop(builder, allSettings, "Deathmatch");
            Elimination?.ToWorkshop(builder, allSettings, "Elimination");
            Escort?.ToWorkshop(builder, allSettings, "Escort");
            Hybrid?.ToWorkshop(builder, allSettings, "Hybrid");
            PracticeRange?.ToWorkshop(builder, allSettings, "PracticeRange");
            Skirmish?.ToWorkshop(builder, allSettings, "Skirmish");
            TeamDeathmatch?.ToWorkshop(builder, allSettings, "TeamDeathmatch");

            builder.Unindent();
            builder.AppendLine("}");
        }
コード例 #3
0
 public void selectshotgun()
 {
     Fire_Button.shotgun = true;
     Difficulty.count    = Difficulty.count - 2;
     decrement           = true;
     Shotgun.SetActive(true);
     Assault.SetActive(false);
 }
コード例 #4
0
 // Start is called before the first frame update
 void Start()
 {
     decrement = false;
     Assault.SetActive(true);
     Revolver.SetActive(false);
     Shotgun.SetActive(false);
     animator = panel.GetComponent <Animator>();
 }
コード例 #5
0
ファイル: Manager.cs プロジェクト: Freamy/EnCoOrszagos
        public static void BuildAssault(string name, int[] forces)
        {
            using (var context = new ApplicationDbContext())
            {
                Country c = context.Countries.FirstOrDefault(m => m.Name == name);
                int     activeCountryId = context.Users.First(m => m.UserName == System.Web.HttpContext.Current.User.Identity.Name).Country.Id;
                if (c != null)
                {
                    Country origin = context.Countries.FirstOrDefault(m => m.Id == activeCountryId);

                    Force archers = new Force()
                    {
                        Size = forces[0],
                        Type = context.UnitTypes.First(m => m.Name == "Archer")
                    };
                    if (origin.StandingForce.FirstOrDefault(m => m.Type.Name == "Archer") != null)
                    {
                        origin.StandingForce.First(m => m.Type.Name == "Archer").Size = origin.StandingForce.First(m => m.Type.Name == "Archer").Size - forces[0];
                    }
                    List <Force> forcesList = new List <Force>();
                    forcesList.Add(archers);

                    Force knights = new Force()
                    {
                        Size = forces[1],
                        Type = context.UnitTypes.First(m => m.Name == "Knight")
                    };

                    if (origin.StandingForce.FirstOrDefault(m => m.Type.Name == "Knight") != null)
                    {
                        origin.StandingForce.First(m => m.Type.Name == "Knight").Size = origin.StandingForce.First(m => m.Type.Name == "Knight").Size - forces[1];
                    }
                    forcesList.Add(knights);

                    Force Elites = new Force()
                    {
                        Size = forces[2],
                        Type = context.UnitTypes.First(m => m.Name == "Elite")
                    };

                    if (origin.StandingForce.FirstOrDefault(m => m.Type.Name == "Elite") != null)
                    {
                        origin.StandingForce.First(m => m.Type.Name == "Elite").Size = origin.StandingForce.First(m => m.Type.Name == "Elite").Size - forces[2];
                    }
                    forcesList.Add(Elites);

                    Assault assault = new Assault();
                    assault.Forces = forcesList;
                    assault.Target = c;

                    origin.Assaults.Add(assault);

                    context.Assaults.Add(assault);
                    context.SaveChanges();
                }
            }
        }
コード例 #6
0
 public void selectassault()
 {
     if (decrement == true)
     {
         Difficulty.count = Difficulty.count + 2;
     }
     Shotgun.SetActive(false);
     Assault.SetActive(true);
 }
コード例 #7
0
    public Assault SelectAssault()
    {
        //权重,随机,限制
        //create universal move assault??
        float sum = 0f;

        foreach (Assault asst in Assaults.Values)
        {
            if (asst.CanUse(Target) == ResultType.SUCCESS)
            {
                sum += asst.Data.Weight;
            }
        }

        AssaultWeights.Clear();
        wegts.Clear();
        int num = 0;

        foreach (var kv in Assaults)
        {
            if (kv.Value.CanUse(Target) == ResultType.SUCCESS)
            {
                wegts.Add(kv.Value.Data.Weight / sum);
                AssaultWeights[num] = kv.Key;
                num++;
            }
        }

        wegtsum.Clear();
        wegtsum.AddRange(wegts);
        for (int i = 0; i < wegts.Count; i++)
        {
            for (int j = 0; j < i; j++)
            {
                wegtsum[i] += wegts[j];
            }
        }

        float rand = Random.Range(0f, 1f);

        for (int i = 0; i < wegtsum.Count; i++)
        {
            if (wegtsum[i] >= rand)
            {
                AssaultExtension aset = GetAssaultById(AssaultWeights[i]);
                CurAssault = aset;
                return(aset);
            }
        }

        return(null);
    }
コード例 #8
0
    public override TaskStatus OnUpdate()
    {
        Assault ast = sdself.Value.SelectAssault();

        if (ast == null)
        {
            return(TaskStatus.Failure);
        }
        else
        {
            return(TaskStatus.Success);
        }
    }
コード例 #9
0
    private void Attack()
    {
        Assault assault = GetComponent <Assault>();

        Transform target = FindClosestTarget();

        self.destination = target.position;

        self.stoppingDistance = 1f;

        if (Vector3.Distance(transform.position, target.position) <= 2.5f && CanAttack())
        {
            timeSinceLastAttack = 0f;
            assault.DealDamage(target, GetComponent <Character_interaction>().damage_fl);
        }
    }
コード例 #10
0
 public void UseAssault(Assault ast, Role target)
 {
     Cmds.Clear();
     ast.Start(target);
 }
コード例 #11
0
    public static void Main()
    {
        var            input      = Console.ReadLine();
        List <Assault> stats      = new List <Assault>();
        var            singleUnit = new Assault();

        while (input != "Count em all")
        {
            var tokens = input.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries).Select(a => a.Trim()).ToList();

            string region     = tokens[0];
            string meteorType = tokens[1];
            int    count      = int.Parse(tokens[2]);

            if (!stats.Any(a => a.Region == region))
            {
                singleUnit.Region = region;
                if (count >= MaxValue && meteorType != "Black")
                {
                    string newMeteorType = ChangeMeteorType(meteorType);
                    singleUnit.MeteorType[newMeteorType] += count / MaxValue;
                    count %= MaxValue;
                }

                singleUnit.MeteorType[meteorType] += count;

                stats.Add(singleUnit);
                singleUnit = new Assault();
            }
            else
            {
                int index = stats.FindIndex(a => a.Region == region);
                stats[index].MeteorType[meteorType] += count;

                if (stats[index].MeteorType[meteorType] >= MaxValue && meteorType != "Black")
                {
                    long newCount = stats[index].MeteorType[meteorType] / MaxValue;
                    stats[index].MeteorType[meteorType] = stats[index].MeteorType[meteorType] % MaxValue;
                    string newMeteorType = ChangeMeteorType(meteorType);
                    stats[index].MeteorType[newMeteorType] += newCount;

                    if (newMeteorType == "Red" && stats[index].MeteorType[newMeteorType] >= MaxValue)
                    {
                        newCount = stats[index].MeteorType[newMeteorType] / MaxValue;
                        stats[index].MeteorType[newMeteorType] = stats[index].MeteorType[newMeteorType] % MaxValue;
                        newMeteorType = "Black";
                        stats[index].MeteorType[newMeteorType] += newCount;
                    }
                }
            }
            input = Console.ReadLine();
        }
        Console.WriteLine();

        var order = stats.OrderByDescending(r => r.MeteorType["Black"])
                    .ThenBy(n => n.Region.Length)
                    .ThenBy(a => a.Region);

        foreach (var region in order)
        {
            Console.WriteLine(region.Region);
            foreach (var meteor in region.MeteorType.OrderByDescending(c => c.Value).ThenBy(n => n.Key))
            {
                Console.WriteLine($"-> {meteor.Key} : {meteor.Value}");
            }
        }
    }