Beispiel #1
0
    public void Start()
    {
        DropDownPlayerPosition.value = (int)TestPlayer.Attributes.Zone;

        List <string> list = new List <string>();

        foreach (PlayerStrategyData.PlayerStrategyChances strategy in GameData.Instance.PlayerStrategies)
        {
            list.Add(strategy.Strategy.ToString());
        }
        DropDownPlayerStrategy.AddOptions(list);
        DropDownPlayerStrategy.value = (int)TestPlayer.Attributes.Strategy;

        list.Clear();
        foreach (Team_Strategy strategy in GameData.Instance.TeamStrategies)
        {
            list.Add(strategy.Name);
        }
        DropDownTeamStrategy.AddOptions(list);
        TeamStrategy = (TeamStrategy)DropDownTeamStrategy.value;

        list.Clear();
        DropDownPlayerPosition.ClearOptions();
        for (int i = 0; i < 31; i++)
        {
            list.Add(((Zone)i).ToString());
        }
        DropDownPlayerPosition.AddOptions(list);

        TestPlayer.Attributes.Strategy = (PlayerStrategy)DropDownPlayerStrategy.value;

        Test();
    }
Beispiel #2
0
 public Team(World world, string name, TeamStrategy strategy, IEnumerable<SquadMember> squad)
 {
     World = world;
     Name = name;
     Strategy = strategy;
     Squad = squad.ToList();
 }
    void Start()
    {
        posCamping1 = new Vector3(18, 0, -21);

        posCamping0 = new Vector3(-18, 0, 21);



        teamStrategy = TeamStrategy.Advanced;

        master = FindObjectOfType <GameMaster>();
        team   = transform.parent.GetComponent <Team> ();

        teamID = team.team_ID;



        ourFlagLastKnownPosition   = team.team_base.position;
        theirFlagLastKnownPosition = team.enemy_base.position;



        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Bot"))
        {
            if (go.GetComponent <Bot> ().team_ID != teamID)
            {
                ennemies.Add(go);
            }
        }
    }
Beispiel #4
0
    public void ValueChange()
    {
        Zone pos = (Zone)DropDownPlayerPosition.value;

        //teamStrategy = MainController.Instance.TeamStrategyData.team_Strategys[DropDownTeamStrategy.value];
        TeamStrategy = (TeamStrategy)DropDownTeamStrategy.value;
        TestPlayer.Attributes.Zone = pos;
        Test();
    }
        public int CreateTeam(int worldId, string name, TeamStrategy strategy, IEnumerable<Tuple<PositionCode, int>> squad)
        {
            var world = Context.Worlds.Find(worldId);
            var team = new Team(world, name, strategy,
                squad.Select(s => new SquadMember(s.Item1, s.Item2)).ToArray());

            Context.Teams.Add(team);
            Context.SaveChanges();

            return team.Id;
        }
Beispiel #6
0
    public Zones GetPosChanceData(TeamStrategy _strategy, Zone _zone)
    {
        foreach (PosChanceData data in StrategyPosChanceData)
        {
            if (data.Strategy == _strategy)
            {
                return(data.posChancePerZones[(int)_zone]);
            }
        }

        return(null);
    }
Beispiel #7
0
    public Zone GetTargetZone(PlayInfo _playInfo)
    {
        Zone         zone          = _playInfo.AttackingTeam.GetTeamZone(_playInfo.Zone);
        MatchEvent   _event        = _playInfo.Event;
        PlayerAction _action       = _playInfo.OffensiveAction;
        TeamStrategy _teamStrategy = _playInfo.AttackingTeam.Strategy;
        bool         _isAwayTeam   = _playInfo.AttackingTeam.IsAwayTeam;

        List <KeyValuePair <Zone, float> > list = new List <KeyValuePair <Zone, float> >();

        _OwnGoal = 0;
        _BLD     = 0;
        _BRD     = 0;

        _LD  = 0;
        _LCD = 0;
        _CD  = 0;
        _RCD = 0;
        _RD  = 0;

        _LDM  = 0;
        _LCDM = 0;
        _CDM  = 0;
        _RCDM = 0;
        _RDM  = 0;

        _LM  = 0;
        _LCM = 0;
        _CM  = 0;
        _RCM = 0;
        _RM  = 0;

        _LAM  = 0;
        _LCAM = 0;
        _CAM  = 0;
        _RCAM = 0;
        _RAM  = 0;

        _LF  = 0;
        _LCF = 0;
        _CF  = 0;
        _RCF = 0;
        _RF  = 0;

        _ALF = 0;
        _ARF = 0;
        _Box = 0;

        if (_event == MatchEvent.Goalkick)
        {
            _LDM  = 0.15f;
            _LCDM = 0.15f;
            _CDM  = 015f;
            _RCDM = 0.15f;
            _RDM  = 0.15f;
            _LM   = 1f;
            _LCM  = 1f;
            _CM   = 1f;
            _RCM  = 1f;
            _RM   = 1f;
            _LAM  = 0.5f;
            _LCAM = 0.5f;
            _CAM  = 0.5f;
            _RCAM = 0.5f;
            _RAM  = 0.5f;
        }

        else if (_action == PlayerAction.Pass || _action == PlayerAction.Dribble || _action == PlayerAction.Sprint)
        {
            TargetPassPerZone data = GameData.Instance.TargetPassPerZone[(int)zone];

            _OwnGoal = data.OwnGoal;
            _BLD     = data.BLD;
            _BRD     = data.BRD;

            _LD  = data.LD;
            _LCD = data.LCD;
            _CD  = data.CD;
            _RCD = data.RCD;
            _RD  = data.RD;

            _LDM  = data.LDM;
            _LCDM = data.LCDM;
            _CDM  = data.CDM;
            _RCDM = data.RCDM;
            _RDM  = data.RDM;

            _LM  = data.LM;
            _LCM = data.LCM;
            _CM  = data.CM;
            _RCM = data.RCM;
            _RM  = data.RM;

            _LAM  = data.LAM;
            _LCAM = data.LCAM;
            _CAM  = data.CAM;
            _RCAM = data.RCAM;
            _RAM  = data.RAM;

            _LF  = data.LF;
            _LCF = data.LCF;
            _CF  = data.CF;
            _RCF = data.RCF;
            _RF  = data.RF;

            _ALF = data.ALF;
            _ARF = data.ARF;
            _Box = data.Box;
        }

        else if (_action == PlayerAction.Cross || _action == PlayerAction.LongPass)
        {
            CrossTargetPerZoneData.TargetCrossPerZone data = GameData.Instance.TargetCrossPerZone[(int)zone];

            _OwnGoal = data.OwnGoal;
            _BLD     = data.BLD;
            _BRD     = data.BRD;

            _LD  = data.LD;
            _LCD = data.LCD;
            _CD  = data.CD;
            _RCD = data.RCD;
            _RD  = data.RD;

            _LDM  = data.LDM;
            _LCDM = data.LCDM;
            _CDM  = data.CDM;
            _RCDM = data.RCDM;
            _RDM  = data.RDM;

            _LM  = data.LM;
            _LCM = data.LCM;
            _CM  = data.CM;
            _RCM = data.RCM;
            _RM  = data.RM;

            _LAM  = data.LAM;
            _LCAM = data.LCAM;
            _CAM  = data.CAM;
            _RCAM = data.RCAM;
            _RAM  = data.RAM;

            _LF  = data.LF;
            _LCF = data.LCF;
            _CF  = data.CF;
            _RCF = data.RCF;
            _RF  = data.RF;

            _ALF = data.ALF;
            _ARF = data.ARF;
            _Box = data.Box;
        }

        if (_event != MatchEvent.Goalkick)
        {
            Team_Strategy strategy = GameData.Instance.TeamStrategies[(int)_teamStrategy];
            _OwnGoal *= strategy.Target_OwnGoal;
            _BLD     *= strategy.Target_BLD;
            _BRD     *= strategy.Target_BRD;

            _LD  *= strategy.Target_LD;
            _LCD *= strategy.Target_LCD;
            _CD  *= strategy.Target_CD;
            _RCD *= strategy.Target_RCD;
            _RD  *= strategy.Target_RD;

            _LDM  *= strategy.Target_LDM;
            _LCDM *= strategy.Target_LCDM;
            _CDM  *= strategy.Target_CDM;
            _RCDM *= strategy.Target_RCDM;
            _RDM  *= strategy.Target_RDM;

            _LM  *= strategy.Target_LM;
            _LCM *= strategy.Target_LCM;
            _CM  *= strategy.Target_CM;
            _RCM *= strategy.Target_RCM;
            _RM  *= strategy.Target_RM;

            _LAM  *= strategy.Target_LAM;
            _LCAM *= strategy.Target_LCAM;
            _CAM  *= strategy.Target_CAM;
            _RCAM *= strategy.Target_RCAM;
            _RAM  *= strategy.Target_RAM;

            _LF  *= strategy.Target_LF;
            _LCF *= strategy.Target_LCF;
            _CF  *= strategy.Target_CF;
            _RCF *= strategy.Target_RCF;
            _RF  *= strategy.Target_RF;

            _ALF *= strategy.Target_ALF;
            _ARF *= strategy.Target_ARF;
            _Box *= strategy.Target_Box;
        }


        float total =
            _OwnGoal + _BLD + _BRD +
            _LD + _LCD + +_CD + _RCD + _RD +
            _LDM + _LCDM + +_CDM + _RCDM + _RDM +
            _LM + _LCM + _CM + _RCM + _RM +
            _LAM + _LCAM + _CAM + _RCAM + _RAM +
            _LF + _LCF + _CF + _RCF + _RF +
            _ALF + _ARF + _Box;

        _OwnGoal /= total;
        _BLD     /= total;
        _BRD     /= total;

        _LD  /= total;
        _LCD /= total;
        _CD  /= total;
        _RCD /= total;
        _RD  /= total;

        _LDM  /= total;
        _LCDM /= total;
        _CDM  /= total;
        _RCDM /= total;
        _RDM  /= total;

        _LM  /= total;
        _LCM /= total;
        _CM  /= total;
        _RCM /= total;
        _RM  /= total;

        _LAM  /= total;
        _LCAM /= total;
        _CAM  /= total;
        _RCAM /= total;
        _RAM  /= total;

        _LF  /= total;
        _LCF /= total;
        _CF  /= total;
        _RCF /= total;
        _RF  /= total;

        _ALF /= total;
        _ARF /= total;
        _Box /= total;

        list.Add(new KeyValuePair <Zone, float>(Zone.OwnGoal, _OwnGoal));
        list.Add(new KeyValuePair <Zone, float>(Zone.BLD, _BLD));
        list.Add(new KeyValuePair <Zone, float>(Zone.BRD, _BRD));

        list.Add(new KeyValuePair <Zone, float>(Zone.LD, _LD));
        list.Add(new KeyValuePair <Zone, float>(Zone.LCD, _LCD));
        list.Add(new KeyValuePair <Zone, float>(Zone.CD, _CD));
        list.Add(new KeyValuePair <Zone, float>(Zone.RCD, _RCD));
        list.Add(new KeyValuePair <Zone, float>(Zone.RD, _RD));

        list.Add(new KeyValuePair <Zone, float>(Zone.LDM, _LDM));
        list.Add(new KeyValuePair <Zone, float>(Zone.LCDM, _LCDM));
        list.Add(new KeyValuePair <Zone, float>(Zone.CDM, _CDM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RCDM, _RCDM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RDM, _RDM));

        list.Add(new KeyValuePair <Zone, float>(Zone.LM, _LM));
        list.Add(new KeyValuePair <Zone, float>(Zone.LCM, _LCM));
        list.Add(new KeyValuePair <Zone, float>(Zone.CM, _CDM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RCM, _RCM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RM, _RM));

        list.Add(new KeyValuePair <Zone, float>(Zone.LAM, _LAM));
        list.Add(new KeyValuePair <Zone, float>(Zone.LCAM, _LCAM));
        list.Add(new KeyValuePair <Zone, float>(Zone.CAM, _CAM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RCAM, _RCAM));
        list.Add(new KeyValuePair <Zone, float>(Zone.RAM, _RAM));

        list.Add(new KeyValuePair <Zone, float>(Zone.LF, _LF));
        list.Add(new KeyValuePair <Zone, float>(Zone.LCF, _LCF));
        list.Add(new KeyValuePair <Zone, float>(Zone.CF, _CF));
        list.Add(new KeyValuePair <Zone, float>(Zone.RCF, _RCF));
        list.Add(new KeyValuePair <Zone, float>(Zone.RF, _RF));

        list.Add(new KeyValuePair <Zone, float>(Zone.ALF, _ALF));
        list.Add(new KeyValuePair <Zone, float>(Zone.ARF, _ARF));
        list.Add(new KeyValuePair <Zone, float>(Zone.Box, _Box));

        Zone  target     = zone;
        float random     = Random.Range(0.00001f, 1f);
        float cumulative = 0;

        for (int i = 0; i < list.Count; i++)
        {
            cumulative += list[i].Value;
            if (random < cumulative)
            {
                target = list[i].Key;
                break;
            }
        }
        if (_isAwayTeam)
        {
            return(GetAwayTeamZone(target));
        }
        else
        {
            return(target);
        }
    }
Beispiel #8
0
        public double ChanceToReceivePass(Player passingPlayer, TeamStrategy strategy)
        {
            if (passingPlayer == this)
            {
                return 0;
            }
            else
            {
                int distanceForward = passingPlayer.Position.DistanceForward(Position);
                int distanceSideways = passingPlayer.Position.DistanceSideways(Position);

                double chance = 1;
                
                if (distanceForward > 0)
                {
                    chance = 10.0 / distanceForward;
                }
                else if (distanceForward == 0)
                {
                    chance = 5.0;
                }
                else
                {
                    chance = 1.0 / (-distanceForward);
                }

                if (distanceSideways > 0)
                {
                    chance /= distanceSideways;
                }

                if (IsStrategicPlayer(strategy) && !passingPlayer.IsStrategicPlayer(strategy))
                {
                    chance *= 1.5;
                }

                if (IsForward)
                {
                    chance *= 2.0;
                }

                if (IsGoalkeeper)
                {
                    chance /= 5;
                }

                return chance;
            }
        }
Beispiel #9
0
        public double ChanceToInitiateAttack(TeamStrategy strategy)
        {
            double baseChance = InitiateAttackChanceByPosition[Position];

            if (IsStrategicPlayer(strategy))
            {
                baseChance *= 2.0;
            }

            return baseChance;
        }
Beispiel #10
0
 public bool IsStrategicPlayer(TeamStrategy strategy)
 {
     return
         (strategy == TeamStrategy.Center && IsCenterMidfielder) ||
         (strategy == TeamStrategy.Wings && IsWinger) ||
         (strategy == TeamStrategy.Playmaker && Position == Position.CenterAttackingMidfielder);
 }
Beispiel #11
0
 public Team(string name, TeamStrategy strategy)
 {
     Name = name;
     Strategy = strategy;
 }
Beispiel #12
0
 public TeamBuilder WithStrategy(TeamStrategy strategy)
 {
     this.strategy = strategy;
     return this;
 }
    void Update()
    {
        timerStrat += Time.deltaTime;

        // STRATEGIE DE BASE

        if (teamStrategy == TeamStrategy.AttackFlag)
        {
            if (!flagDefenser)
            {
                flagDefenser = GetCloser(team.team_base.position);

                flagDefenser.GetComponent <BotBehaviourDeusVult> ().SwitchState(BotBehaviourDeusVult.BotState.DefenseProtectBase);
            }
        }



        // STRATEGIE DEFENSE

        else if (teamStrategy == TeamStrategy.Defense)
        {
            if (!flagDefenser)
            {
                flagDefenser = GetCloser(team.team_base.position);

                flagDefenser.GetComponent <BotBehaviourDeusVult> ().SwitchState(BotBehaviourDeusVult.BotState.DefenseProtectBase);
            }


            if (!sideCamper)
            {
                Vector3 posCamping = Vector3.zero;

                if (teamID == 1)
                {
                    posCamping = posCamping1;
                }
                else
                {
                    posCamping = posCamping0;
                }


                sideCamper = GetCloser(posCamping);

                sideCamper.GetComponent <BotBehaviourDeusVult> ().SwitchState(BotBehaviourDeusVult.BotState.DefensePlantATent);
            }
        }


        // Stratégie avancée

        else if (teamStrategy == TeamStrategy.Advanced)
        {
            if (!flagDefenser)
            {
                flagDefenser = GetCloser(team.team_base.position);

                flagDefenser.GetComponent <BotBehaviourDeusVult> ().SwitchState(BotBehaviourDeusVult.BotState.DefenseProtectBase);
            }


            if (!sideCamper)
            {
                Vector3 posCamping = Vector3.zero;

                if (teamID == 1)
                {
                    posCamping = posCamping1;
                }
                else
                {
                    posCamping = posCamping0;
                }


                sideCamper = GetCloser(posCamping);

                sideCamper.GetComponent <BotBehaviourDeusVult> ().SwitchState(BotBehaviourDeusVult.BotState.DefensePlantATent);
            }
        }



        //MAJ Variables

        int flagCarrier = master.GetFlagCarrierID((teamID + 1) % 2);

        if (flagCarrier > -1)           // On a récupéré le drapeau


        {
            weStoleTheirFlag = true;

            theirFlagLastKnownPosition = master.GetBotFromID(flagCarrier).transform.position;
        }

        else
        {
            weStoleTheirFlag = false;
        }



        if (master.is_flag_home [teamID])
        {
            theyStoleOurFlag = false;
        }



        else
        {
            theyStoleOurFlag = true;
        }



        if (master.GetScore(teamID) > pointsTeam)
        {
            BroughtBackTheirFlag();
            pointsTeam++;
            timerStrat = 0;
        }

        if (master.GetScore((teamID + 1) % 2) > pointsEnnemy)
        {
            BroughtBackOurFlag();
            pointsEnnemy++;
        }


        if (master.GetFlagCarrierID((teamID + 1) % 2) == -1)
        {
            BroughtBackOurFlag();
        }

        if (master.GetFlagCarrierID(teamID) == -1)
        {
            BroughtBackTheirFlag();
        }

        if (timerStrat >= 120)
        {
            teamStrategy = TeamStrategy.Defense;
        }
    }