Inheritance: MonoBehaviour
Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        team = transform.parent.GetComponent<TeamNumber>();

        startPos = transform.position;

        /*Select your pathfinding
        graph = new Pathfinding();
        graph.Load(PlayerPrefs.GetString("Pierre"));
        graph.setNeighbors();
        */
        nav = GetComponent<NavMeshAgent>();
        nav.speed = 10;
        nav.acceleration = 20;
        nav.stoppingDistance = 5;

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Target"))
        {
            targets.Add(go);
        }
        targets.Remove(gameObject);

        //road = PathfindingManager.GetInstance().GetRoad(transform.position, target.transform.position,graph);
        if (strat == Strat.IDontKnow)
        {
            InvokeRepeating("UpdateRoadRandom", 0.1f, 5f);
        }

        InvokeRepeating("UpdateRoad", 0.1f, 0.1f);
        //Debug.Log(PathfindingManager.GetInstance().test);
        InvokeRepeating("Fire", 0f, 1f);
    }
Exemplo n.º 2
0
    void Start()
    {
        WSU = gameObject.GetComponent <WorldStateUpdater>();
        Debug.Log("World State Updater" + WSU);
        teamNumber = WSU.thisTeamNumber;

        scene   = GameObject.FindWithTag("GameManager").GetComponent <SceneBuilder>();
        spawner = scene.base2.GetComponent <Spawner>();
    }
Exemplo n.º 3
0
        public SpawnTroopAction(GoapAgent agent) : base(agent)
        {
            //preconditions.Add(Effects.HAS_SUFFICIENT_GOLD, true);
            //effects.Add(Effects.HAS_SUFFICIENT_GOLD, true);

            //distanceMultiplier = 0.5f;
            // requiredRange = 4f;
            cost            = 30;
            this.teamNumber = GameObject.FindWithTag("Player2").GetComponent <PlayerGOAPAI>().teamNumber;
            // this.targetPlayerId = targetPlayerId;
        }
        public MatchInfoViewModel()
        {
            NavigateHomeCommand = new RelayCommand(NavigateHome, () => {
                return(!_Navigating);
            });
            SubmitCommand = new RelayCommand(Submit, () => {
                if (_Navigating)
                {
                    return(false);
                }
                if (!SelectedRecorderID.Any())
                {
                    return(false);
                }
                if (!SelectedAlliance.Any())
                {
                    return(false);
                }
                if (!SelectedEvent.Any())
                {
                    return(false);
                }
                if (!MatchNumber.Any())
                {
                    return(false);
                }
                if (!TeamNumber.Any())
                {
                    return(false);
                }
                return(true);
            });
            NavigateHomeCommand.RaiseCanExecuteChanged();
            SubmitCommand.RaiseCanExecuteChanged();

            Messenger.Default.Send(new Message.RetrieveDataMessage <Model.MatchInfoSource>()
            {
                SetData = (MatchInfoSource matchInfoSource) => {
                    RecorderIDSource = matchInfoSource.RecorderIDSource;
                    AllianceSource   = matchInfoSource.AllianceSource;
                    EventSource      = matchInfoSource.EventSource;
                }
            });
            Messenger.Default.Send(new Message.RetrieveDataMessage <Model.MatchInfo>()
            {
                SetData = (MatchInfo matchInfo) => {
                    SelectedRecorderID = matchInfo.RecorderID;
                    SelectedAlliance   = matchInfo.Alliance;
                    SelectedEvent      = matchInfo.Event;
                    MatchNumber        = Convert.ToString(matchInfo.MatchNumber);
                    TeamNumber         = Convert.ToString(matchInfo.TeamNumber);
                }
            });
        }
Exemplo n.º 5
0
 /// <summary>
 /// 構築
 /// </summary>
 /// <param name="name"></param>
 /// <param name="initialName"></param>
 /// <param name="teamNumber"></param>
 public TeamSetting(string name, string initialName, TeamNumber teamNumber)
 {
     Name = name;
     InitialName = initialName;
     TeamNumber = teamNumber;
     DefaultGameMembers = new List<GameMember>();
     DefaultOutSideMembers = new List<GameMember>();
     CurrentGameMembers = new List<GameMember>();
     CurrentChangedMembers = new List<GameMember>();
     CurrentOutSideMembers = new List<GameMember>();
 }
Exemplo n.º 6
0
    private static bool IsTeamFull(TeamNumber team)
    {
        int count = 0;

        foreach (TeamNumber t in teamMap.Values)
        {
            if (t == team)
            {
                count++;
            }
        }
        return(count >= 2);
    }
Exemplo n.º 7
0
    void Start()
    {
        scene = GameObject.FindWithTag("GameManager").GetComponent <SceneBuilder>();
        // thisTeamNumber = GetComponent<PlayerGOAPAI>().teamNumber;
        thisTeamNumber = TeamNumber.t2;
        Debug.Log("WSU Team NUmber: " + thisTeamNumber);
        player2AI = GetComponent <PlayerGOAPAI>();
        spawner   = scene.base2.GetComponent <Spawner>();
        Debug.Log("WSU spawner assigned" + spawner);
        classCounts        = new int[scene.unitPrefabs.Length];
        enemiesCloseToBase = new List <GameObject>();
        alliesCloseToBase  = new List <GameObject>();

        // goapAction = GetComponent<GoapAction>();
    }
Exemplo n.º 8
0
    public static bool AssignPlayerToTeam(PlayerNumber player, TeamNumber team)
    {
        if (team == TeamNumber.NULL)
        {
            return(false);
        }

        // If team is not full, assign to team
        if (!IsTeamFull(team))
        {
            teamMap[player] = team;
            return(true);
        }

        return(false);
    }
Exemplo n.º 9
0
    public bool canAffordTroop(TeamNumber teamNumber, TroopClass troopClass)
    {
        //Debug.Log("Team Number : " + ((int)teamNumber));
        // Debug.Log("TroopClass  : " + ((int)troopClass));
        int playerGold = playerGoldCounts[(int)teamNumber - 1];
        int troopCost  = troopCosts[troopClass];

        if (playerGold >= troopCost)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 10
0
        private void TeamNumber_Unfocused(object sender, FocusEventArgs e)
        {
            bool valid = false;

            foreach (string team in _teams)
            {
                if (TeamNumber.Text == team || string.IsNullOrWhiteSpace(TeamNumber.Text))
                {
                    valid = true;
                    break;
                }
            }
            if (!valid)
            {
                DisplayAlert("Invalid Team Number", "The team number you entered does not match any of the teams at this event", "OK");
                TeamNumber.Focus();
            }
        }
Exemplo n.º 11
0
    public Unit CreateUnit(TroopClass troopClass, TeamNumber teamNumber)
    {
        GameObject unitGO     = null;
        Unit       unitScript = null;

        float randSpawnLoc = Random.Range(-(spawner.spawnRange), spawner.spawnRange);

        //Debug.Log("TroopClass of troop about to be spawned is : " + (int)troopClass);
        unitGO     = Instantiate(unitsPrefabs[(int)troopClass], (this.transform.position + new Vector3(0, randSpawnLoc, 0)), Quaternion.identity) as GameObject;
        unitScript = unitGO.GetComponent <Unit>();
        unitScript.Initialize(troopClass, teamNumber);
        scene.subtractUnitCost(troopClass, teamNumber);
        scene.getTroopsList().Add(unitGO);
        //Debug.Log("Troop  Team Number : " + unitGO.GetComponent<Unit>().ThisTeamNumber);
        //Debug.Log("Spawner  Team Number : " + spawner.thisteamNumber);

        return(unitScript);
    }
Exemplo n.º 12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (TeamNumber != 0)
            {
                hash ^= TeamNumber.GetHashCode();
            }
            hash ^= ids_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 13
0
 public void partitionTroopsList()
 {
     allyTroops.Clear();
     enemyTroops.Clear();
     foreach (GameObject unitGO in Units)
     {
         TeamNumber unitTeamNumber = unitGO.GetComponent <Unit>().ThisTeamNumber;
         if (thisTeamNumber == unitTeamNumber)
         {
             allyTroops.Add(unitGO);
         }
         else if (thisTeamNumber != unitTeamNumber)
         {
             enemyTroops.Add(unitGO);
         }
         //Debug.Log("Unit : " + unitGO + " Unit TeamNumber : " + unitTeamNumber + " WSU teamNumber " + thisTeamNumber);
     }
     //Debug.Log("Ally Troops : " + allyTroops.Count);
     //Debug.Log("Enemy Troops" + enemyTroops.Count);
 }
Exemplo n.º 14
0
        public async Task <Match> EditAsync(int id, TeamNumber winningTeam, string team1, string team2)
        {
            if (MatchConfiguration.ForceEightPlayerTeams)
            {
                if (team1.Count(c => c == ',') != 7 ||
                    team2.Count(c => c == ',') != 7)
                {
                    throw new ArgumentException(ExceptionMessage.InvalidMatchSize);
                }
            }

            Match match = await _context.Matches.SingleAsync(m => m.Id == id);

            match.WinningTeam = winningTeam;
            match.Team1       = team1;
            match.Team2       = team2;
            await _context.SaveChangesAsync();

            return(match);
        }
Exemplo n.º 15
0
    public override void Awake()
    {
        base.Awake();

        TeamNumber teamNumber = TeamNumber.t2;

        WSU = GetComponent <WorldStateUpdater>();
        // create goals

        goals.Add(GoapGoal.Goals.DEFEND_HOME_BASE, new DefendBaseGoal(GoapGoal.Goals.DEFEND_HOME_BASE, 1f));

        goals.Add(GoapGoal.Goals.KILL_ENEMY_BASE, new KillEnemyBaseGoal(GoapGoal.Goals.KILL_ENEMY_BASE, 1f));

        goals.Add(GoapGoal.Goals.SPAWN_TROOPS, new SpawnTroops(GoapGoal.Goals.SPAWN_TROOPS, 0.5f));

        // create Actions

        dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_WARRIOR, false);
        dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_ARCHER, false);
        dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_MAGE, false);
        dataSet.SetData(GoapAction.Effects.HAS_SUFFICIENT_GOLD_GATHERER, false);

        dataSet.SetData(GoapAction.Effects.ALLIES_ALIVE, false);
        dataSet.SetData(GoapAction.Effects.ENEMIES_ALIVE, false);
        dataSet.SetData(GoapAction.Effects.RESOURCES_TO_GATHER, false);
        dataSet.SetData(GoapAction.Effects.ENEMIES_NEAR_BASE, false);



        possibleActions.Add(new SpawnTroopAction(this));
        //possibleActions.Add(new WaitForGoldAction(this));
        possibleActions.Add(new SpawnWarrior(this));
        possibleActions.Add(new SpawnArcher(this));
        possibleActions.Add(new SpawnMage(this));
        possibleActions.Add(new SpawnGatherer(this));
        possibleActions.Add(new CommandTroopAttackEnemyTroops(this));
        possibleActions.Add(new CommandTroopAttackEnemyBase(this));
        possibleActions.Add(new CommandTroopDefendHomeBase(this));
    }
Exemplo n.º 16
0
    //RPC calls the server to set the variables, this is called when the object is initialized
    void SetVariables(Vector3 givenDirection, int teamNum)
    {
        if (Network.isServer)
        {
            //Set the direction and the team number of the projectile
            direction = givenDirection.normalized;
            switch (teamNum)
            {
            case 1:
                teamNumber = TeamNumber.TEAM_ONE;
                break;

            case 2:
                teamNumber = TeamNumber.TEAM_TWO;
                break;

            default:
                teamNumber = TeamNumber.OTHER;
                break;
            }
            //Propels the projectile according to its projectile type
            switch (projectileType)
            {
            case ProjectileType.BULLET:
                rigidbody.AddForce(direction * speed, ForceMode.VelocityChange);
                break;

            case ProjectileType.GRENADE:
                rigidbody.AddForce(direction * speed, ForceMode.Impulse);
                break;

            case ProjectileType.ORB:
                rigidbody.AddForce(direction * speed, ForceMode.VelocityChange);
                break;
            }
        }
    }
Exemplo n.º 17
0
    private void Confirm()
    {
        if (moveTween.IsPlaying())
        {
            return;
        }

        TeamNumber team = currentPos < 1 ? TeamNumber.ONE : TeamNumber.TWO;

        if (PlayerToTeamMap.AssignPlayerToTeam(playerNumber, team))
        {
            confirmed          = true;
            leftArrow.enabled  = false;
            rightArrow.enabled = false;
            playerTextElement.DOShakeAnchorPos(confirmTime, confirmShakeStrength, confirmShakeVibrato);
            playerTextElement.DOScale(1.5f, confirmTime);
        }
        else
        {
            Sequence failConfirm = DOTween.Sequence();
            failConfirm.Append(playerTextElement.DOScale(1.2f, confirmTime / 2));
            failConfirm.Append(playerTextElement.DOScale(1f, confirmTime / 2));
        }
    }
        private void NumberBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            int  n      = -1;
            bool worked = int.TryParse(NumberBox.Text, out n);

            if (!worked)
            {
                NumberBox.Text = TeamNumber.ToString();
            }
            else if (ExistingTeams.Contains(n))
            {
                NumberBox.BorderBrush = new SolidColorBrush(Colors.Red);
                NumberBox.ToolTip     = "A team with that number already exists.";
                OKBtn.IsEnabled       = false;
            }
            else
            {
                TeamNumber = n;

                NumberBox.BorderBrush = new SolidColorBrush(GRAY_BORDER);
                NumberBox.ToolTip     = null;

                if (TeamName.Trim() != "")
                {
                    OKBtn.IsEnabled     = true;
                    NameBox.BorderBrush = new SolidColorBrush(GRAY_BORDER);
                    NameBox.ToolTip     = null;
                }
                else
                {
                    OKBtn.IsEnabled     = false;
                    NameBox.BorderBrush = new SolidColorBrush(Colors.Red);
                    NameBox.ToolTip     = "You must specify a name.";
                }
            }
        }
Exemplo n.º 19
0
        public async Task <Match> RecordAsync(TeamNumber winningTeam)
        {
            // Build teams

            IEnumerable <LobbyPlayer> team1 = _context.LobbyPlayers
                                              .Where(p => p.TeamNumber == TeamNumber.Team1)
                                              .OrderBy(p => p.PlayerId); // ordering the IDs ensures that the resulting team string will always be the same for those players

            IEnumerable <LobbyPlayer> team2 = _context.LobbyPlayers
                                              .Where(p => p.TeamNumber == TeamNumber.Team2)
                                              .OrderBy(p => p.PlayerId);


            // Check if 8 vs 8

            if (MatchConfiguration.ForceEightPlayerTeams)
            {
                if (team1.Count() != 8 && team2.Count() != 8)
                {
                    throw new ArgumentException(ExceptionMessage.InvalidMatchSize);
                }
            }


            // Record the match

            Match match = new()
            {
                WinningTeam = winningTeam,
                Team1       = string.Join(',', team1),
                Team2       = string.Join(',', team2)
            };
            await _context.Matches.AddAsync(match);


            // Calculate player rating change

            if (winningTeam != TeamNumber.None)             // if it wasn't a draw
            {
                int team1RatingAvg = (int)team1.Select(p => p.Player.Rating).ToList().Average();
                int team2RatingAvg = (int)team2.Select(p => p.Player.Rating).ToList().Average();
                int maxRatingDiff  = await MaxRatingDiffAsync();

                if (winningTeam == TeamNumber.Team1)
                {
                    foreach (LobbyPlayer winningPlayer in team1)
                    {
                        winningPlayer.Player.Rating = _calc.PlayerRating(winningPlayer.Player.Rating, team2RatingAvg, maxRatingDiff, MatchResult.Win);
                    }
                    foreach (LobbyPlayer losingPlayer in team2)
                    {
                        losingPlayer.Player.Rating = _calc.PlayerRating(losingPlayer.Player.Rating, team1RatingAvg, maxRatingDiff, MatchResult.Lose);
                    }
                }
                else
                {
                    foreach (LobbyPlayer losingPlayer in team1)
                    {
                        losingPlayer.Player.Rating = _calc.PlayerRating(losingPlayer.Player.Rating, team2RatingAvg, maxRatingDiff, MatchResult.Lose);
                    }
                    foreach (LobbyPlayer winningPlayer in team2)
                    {
                        winningPlayer.Player.Rating = _calc.PlayerRating(winningPlayer.Player.Rating, team1RatingAvg, maxRatingDiff, MatchResult.Win);
                    }
                }
            }


            // Done

            await _context.SaveChangesAsync();

            return(match);
        }
    }
Exemplo n.º 20
0
 public static void addGoldNodeGatherer(TeamNumber teamNumber)
 {
     playerXGoldNodesGathered[(int)teamNumber - 1]++;
 }
Exemplo n.º 21
0
        /// <summary>
        /// ランダムでチーム番号を取得
        /// </summary>
        /// <param name="startNumber">開始チーム番号</param>
        /// <param name="endNumber">終了チーム番号</param>
        /// <returns>選択したチーム番号</returns>
        private static TeamNumber GetTeamNumber(TeamNumber startNumber, TeamNumber endNumber)
        {
            // 対戦した回数を算出
            int minMatchCount = int.MaxValue;
            Dictionary<TeamNumber, int> matchUpCount = new Dictionary<TeamNumber, int>();
            for (int i = (int)startNumber; i <= (int)endNumber; i++)
            {
                TeamNumber number = (TeamNumber)i;

                // 直前の試合で戦った相手は除外する(N回目の最後とN+1回目の最初で続くことがあるため)
                if (EVManager.Instance.MatchUpTeamNumbers.Count > 0 &&
                    number == EVManager.Instance.MatchUpTeamNumbers.Last())
                {
                    continue;
                }

                // 2つ前の試合で戦った相手は除外する(県大会と甲子園で同じ相手で対戦したり甲子園で2回対戦してしまうため)
                if (EVManager.Instance.MatchUpTeamNumbers.Count > 1 &&
                    number == EVManager.Instance.MatchUpTeamNumbers[EVManager.Instance.MatchUpTeamNumbers.Count - 2])
                {
                    continue;
                }

                // 対戦回数を格納
                matchUpCount[number] = EVManager.Instance.MatchUpTeamNumbers.Count(m => m == number);

                // 対戦回数の最小値を設定
                if (matchUpCount[number] < minMatchCount)
                {
                    minMatchCount = matchUpCount[number];
                }
            }

            // 対戦回数が最小値のチームのみコレクションに登録
            List<TeamNumber> minTeamNumbers = new List<TeamNumber>();
            foreach (KeyValuePair<TeamNumber, int> keyValuePair in matchUpCount)
            {
                if (keyValuePair.Value == minMatchCount)
                {
                    minTeamNumbers.Add(keyValuePair.Key);
                }
            }

            // ランダムで判定する
            int targetIndex = RandomCreater.GetRandomValue(0, minTeamNumbers.Count - 1);
            return minTeamNumbers[targetIndex];
        }
Exemplo n.º 22
0
 public static void addEnemiesKilled(TeamNumber teamNumber)
 {
     playerXEnemiesKilled[(int)teamNumber - 1]++;
 }
Exemplo n.º 23
0
 public static void setPlayerWinnerNumber(TeamNumber teamNumber)
 {
     playerNumberWinner = teamNumber;
 }
Exemplo n.º 24
0
        /// <summary>
        /// 初期データ作成
        /// (2回以上実行されても問題ない)
        /// </summary>
        /// <param name="topTeamNumber">先行チーム</param>
        /// <param name="bottomTeamNumber">後攻チーム</param>
        private void InitializeData(TeamNumber topTeamNumber, TeamNumber bottomTeamNumber)
        {
            // すでにイベントが接続済みであれば削除する
            if (m_GameManager != null)
            {
                m_GameManager.AfterPitchAndBat -= (GameManager_AfterPitchAndBat);
                m_GameManager.AfterEndBatter -= (GameManager_AfterEndBatter);
                m_GameManager.PassedDefenseTerm -= (GameManager_PassedDefenseTerm);
                m_GameManager.JudgedSafeOrOut -= (GameManager_JudgedSafeOrOut);
            }

            // 対戦チーム同士が自動的に代打・投手交代を行うようにデバッグモードをONにする
            EVManager.Instance.DebugMode = true;

            // マネージャの生成
            TeamSettingBuilder builder = new TeamSettingBuilder();
            m_GameManager = new GameManager(builder.CreateTeamSetting(topTeamNumber), builder.CreateTeamSetting(bottomTeamNumber), true);

            // 守備位置の設定
            GameData gameData = m_GameManager.GameData;
            pictureBox1.Location = CustomPoint.GetPoint(gameData.Defense1Point);
            pictureBox2.Location = CustomPoint.GetPoint(gameData.Defense2Point);
            pictureBox3.Location = CustomPoint.GetPoint(gameData.Defense3Point);
            pictureBox4.Location = CustomPoint.GetPoint(gameData.Defense4Point);
            pictureBox5.Location = CustomPoint.GetPoint(gameData.Defense5Point);
            pictureBox6.Location = CustomPoint.GetPoint(gameData.Defense6Point);
            pictureBox9.Location = CustomPoint.GetPoint(gameData.Defense9Point);
            pictureBox8.Location = CustomPoint.GetPoint(gameData.Defense8Point);
            pictureBox7.Location = CustomPoint.GetPoint(gameData.Defense7Point);

            // ベース位置の設定
            pictureBox15.Location = CustomPoint.GetPoint(Constants.PointFirstBase);
            pictureBox16.Location = CustomPoint.GetPoint(Constants.PointSecondBase);
            pictureBox17.Location = CustomPoint.GetPoint(Constants.PointThirdBase);
            pictureBox18.Location = CustomPoint.GetPoint(Constants.PointHomeBase);

            // フェンスオーバーの目印の設定
            pictureBox19.Location = CustomPoint.GetPoint(Constants.RightFenseOverPoint);
            pictureBox20.Location = CustomPoint.GetPoint(Constants.CenterFenseOverPoint);
            pictureBox21.Location = CustomPoint.GetPoint(Constants.LeftFenseOverPoint);

            // 表示更新
            UpdateGameDataDisplay();

            // イベント接続
            m_GameManager.AfterPitchAndBat += (GameManager_AfterPitchAndBat);
            m_GameManager.AfterEndBatter += (GameManager_AfterEndBatter);
            m_GameManager.PassedDefenseTerm += (GameManager_PassedDefenseTerm);
            m_GameManager.JudgedSafeOrOut += (GameManager_JudgedSafeOrOut);
        }
Exemplo n.º 25
0
 public void AddScore(int s, TeamNumber team)
 {
     teams[(int)team].AddScore(s);
 }
Exemplo n.º 26
0
        /// <summary>
        /// チーム設定の作成
        /// </summary>
        /// <returns></returns>
        public TeamSetting CreateTeamSetting(TeamNumber teamNumber)
        {
            // チーム番号に即したデータを読み込む
            string text = Resources.Resource.ResourceManager.GetString(teamNumber.ToString());

            TeamSetting teamSetting = null;
            int basicValue = 0;
            StringReader reader = new StringReader(text);
            string line;
            int lineCount = 0;
            while ((line = reader.ReadLine()) != null)
            {
                if (lineCount == 0)
                {
                    // 1行目:チーム設定を取得
                    string[] teamSettingString = line.Split(TextSeparator);
                    basicValue = int.Parse(teamSettingString[0]);
                    string initialName = teamSettingString[1];
                    string teamName = teamSettingString[2];
                    teamSetting = new TeamSetting(teamName, initialName, teamNumber);
                }
                else if (lineCount == 1)
                {
                    // 2行目:何もしない
                }
                else if (lineCount >= 20)
                {
                    // 20行目:最大で18人分(LineCountが19)までしか読み込まない
                    break;
                }
                else
                {
                    // 3行目~19行目:能力値の取得
                    string[] memberSettingString = line.Split(TextSeparator);
                    if (memberSettingString[0] == string.Empty)
                    {
                        // 1列目が空文字であればそれ以上のメンバ無しとみなして取得終了
                        break;
                    }
                    int columnIndex = 1;
                    Player player = new Player();
                    DefensePosition defensePosition = (DefensePosition)System.Enum.Parse(typeof(DefensePosition), memberSettingString[columnIndex], true);
                    columnIndex++;
                    player.Name = memberSettingString[columnIndex];
                    columnIndex++;
                    player.Grade = int.Parse(memberSettingString[columnIndex]);
                    columnIndex++;
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        player.IsLeftThrow = bool.Parse(memberSettingString[columnIndex]);
                    }
                    columnIndex++;
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        player.IsLeftBox = bool.Parse(memberSettingString[columnIndex]);
                    }
                    columnIndex++;
                    player.BreedType = (BreedType)System.Enum.Parse(typeof(BreedType), memberSettingString[columnIndex], true);
                    columnIndex++;
                    player.FielderAbility.Meet = int.Parse(memberSettingString[columnIndex]) + basicValue;
                    columnIndex++;
                    player.FielderAbility.Power = int.Parse(memberSettingString[columnIndex]) + basicValue;
                    columnIndex++;
                    player.FielderAbility.Run = int.Parse(memberSettingString[columnIndex]) + basicValue;
                    columnIndex++;
                    player.FielderAbility.Defense = int.Parse(memberSettingString[columnIndex]) + basicValue;
                    columnIndex++;
                    player.FielderAbility.Wisdom = int.Parse(memberSettingString[columnIndex]) + basicValue;
                    columnIndex++;
                    columnIndex++;// [計]列はスキップ
                    // 守備適正は未記入であれば守備位置と同じものを設定
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        player.FielderAbility.DefenseType = (DefenseType)System.Enum.Parse(typeof(DefenseType), memberSettingString[columnIndex], true);
                    }
                    else
                    {
                        player.FielderAbility.DefenseType = DefensePositionHelper.ConvertDefenseType(defensePosition);
                    }
                    columnIndex++;
                    // 起用は未記入であればNomalとする
                    UseKind useKind;
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        useKind = (UseKind)System.Enum.Parse(typeof(UseKind), memberSettingString[columnIndex], true);
                    }
                    else
                    {
                        useKind = UseKind.Normal;
                    }
                    columnIndex++;
                    // 特殊能力
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        player.FielderAbility.SpecialFilederAbility = SpecialAbilityHelper.GetSpecialFielderAbility(memberSettingString[columnIndex]);
                    }
                    columnIndex++;
                    if (memberSettingString[columnIndex] != string.Empty)
                    {
                        // 投手能力が設定されている場合
                        player.PitcherAbility.Fastball = int.Parse(memberSettingString[columnIndex]) + basicValue;
                        columnIndex++;
                        player.PitcherAbility.Breakingball = int.Parse(memberSettingString[columnIndex]) + basicValue;
                        columnIndex++;
                        player.PitcherAbility.Control = int.Parse(memberSettingString[columnIndex]) + basicValue;
                        columnIndex++;
                        player.PitcherAbility.Stamina = int.Parse(memberSettingString[columnIndex]) + basicValue;
                        columnIndex++;
                        columnIndex++;// [計]列はスキップ
                        if (memberSettingString[columnIndex] != string.Empty)
                        {
                            player.PitcherAbility.PitchingStyle = (PitchingStyle)System.Enum.Parse(typeof(PitchingStyle), memberSettingString[columnIndex], true);
                        }
                        columnIndex++;
                        // 投手の特殊能力
                        if (memberSettingString[columnIndex] != string.Empty)
                        {
                            player.PitcherAbility.SpecialPitcherAbility = SpecialAbilityHelper.GetSpecialPitcherAbility(memberSettingString[columnIndex]);
                        }
                    }
                    else
                    {
                        // 投手能力が未設定の場合
                        const int nothingValue = 0;
                        player.PitcherAbility.Fastball = nothingValue;
                        player.PitcherAbility.Breakingball = nothingValue;
                        player.PitcherAbility.Control = nothingValue;
                        player.PitcherAbility.Stamina = nothingValue;
                        player.PitcherAbility.SpecialPitcherAbility = SpecialPitcherAbility.Nothing;

                    }
                    // メンバの作成
                    GameMember member = new GameMember(player, defensePosition);
                    member.UseKind = useKind;
                    teamSetting.DefaultGameMembers.Add(member);
                }
                lineCount++;
            }

            // デフォルトのメンバ設定を元にメンバ設定を作成
            teamSetting.CreateCurrentMembersFromDefault();

            // チーム設定のチェック(よくある設定ミスをチェック)
            CheckTeamSetting(teamSetting);

            return teamSetting;
        }
Exemplo n.º 27
0
 public void subtractUnitCost(TroopClass troopClass, TeamNumber teamNumber)
 {
     playerGoldCounts[(int)teamNumber - 1] -= troopCosts[troopClass];
 }
        protected virtual void Start()
        {
            InitStateMachine();

            detect = transform.FindChild("Trigger").GetComponent<SphereCollider>();
            _bullets = new List<GameObject>();
            parentNumber = transform.parent.parent.GetComponent<TeamNumber>();
            parentNumber.teamName = playerID;
            startPoint = transform.position;
            targets = new List<GameObject>(GameObject.FindGameObjectsWithTag("Target"));
            agent = GetComponent<NavMeshAgent>();
            agent2 = GetComponent<AgentRobin>();

            for (int i = targets.Count - 1; i >= 0; --i)
            {
                if (targets[i].name == "Robin")
                {
                    targets.Remove(targets[i]);
                }
            }
            InvokeRepeating("UpdateSM", 0.1f, 0.2f);
            StartCoroutine(Shoot());
        }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        InitStateMachine();

        team = transform.parent.GetComponent<TeamNumber>();

        startPos = transform.position;

        nav = GetComponent<NavMeshAgent>();
        nav.speed = 10;
        nav.acceleration = 20;
        nav.stoppingDistance = 5;

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Target"))
        {
            targets.Add(go);
        }
        targets.Remove(gameObject);

        InvokeRepeating("UpdateRoad", 0.1f, 0.1f);
        //Debug.Log(PathfindingManager.GetInstance().test);

        StartCoroutine(FireGestion());

        //InvokeRepeating("Fire", 0f, 1f);
    }
Exemplo n.º 30
0
        /// <summary>
        /// 試合結果を反映する
        /// </summary>
        /// <param name="kind">試合結果種別</param>
        /// <param name="schoolGradeKind">対戦校の学校のランク</param>
        /// <param name="teamNumber">対戦チーム番号(リセット時の敗北の場合はs000を指定)</param>
        /// <param name="calledGameWinInning">コールド勝ちした場合のイニング数</param>
        public void ApplyGameResult(GameResultKind kind, SchoolGradeKind schoolGradeKind, TeamNumber teamNumber, int calledGameWinInning)
        {
            // コールド勝ちした場合のイニング数の設定
            CalledGameWinInning = calledGameWinInning;

            // コールド勝ちした場合はEXP増加
            if (CalledGameWinInning > 0)
            {
                foreach (GameMember member in TeamSetting.AllDefaultTeamMembers)
                {
                    if (CalledGameWinInning <= 2)
                    {
                        member.Player.GameExp *= 5;
                    }
                    else if (CalledGameWinInning <= 4)
                    {
                        member.Player.GameExp *= 3;
                    }
                    else if (CalledGameWinInning <= 6)
                    {
                        member.Player.GameExp *= 2;
                    }
                    else if (CalledGameWinInning <= 8)
                    {
                        member.Player.GameExp *= 13 / 10;
                    }
                }
            }

            // 対戦チーム番号の登録
            // (リセット時の敗北の時は登録しない)
            if (teamNumber != TeamNumber.s000)
            {
                MatchUpTeamNumbers.Add(teamNumber);

                // 直近の100件までしか保管しない
                if (MatchUpTeamNumbers.Count > 100)
                {
                    MatchUpTeamNumbers.RemoveAt(0);
                }
            }

            // 学校の評判ポイントの更新
            UpdateSchoolGradePoint(kind, schoolGradeKind);

            // それ以外は試合結果ごとに分岐
            switch (kind)
            {
                case GameResultKind.Win:
                    // 勝利
                    Win++;
                    LatestGameResult = GameResultKind.Win;

                    if (CurrentCup != CupKind.AutumnPreliminary)
                    {
                        // リーグ戦以外
                        if (IsFinalGame)
                        {
                            // 甲子園出場回数を加算
                            if (CurrentCup == CupKind.AutumnCup) SpringKoshienCount++;
                            if (CurrentCup == CupKind.SummerPreliminary) SummerKoshienCount++;
                            // 甲子園優勝回数を加算
                            if (CurrentCup == CupKind.SpringKoshien) SpringKoshienVictoryCount++;
                            if (CurrentCup == CupKind.SummerKoshien) SummerKoshienVictoryCount++;

                            // 決勝戦を勝利した場合は大会終了
                            if (CurrentCup == CupKind.SummerPreliminary || CurrentCup == CupKind.AutumnCup)
                            {
                                // 夏の予算か秋の決勝大会の場合は次の大会の出場権獲得
                                IsPreviousWinner = true;
                            }

                            // 夏の甲子園を優勝すると3年生は引退となる
                            if (CurrentCup == CupKind.SummerKoshien)
                            {
                                Graduate();
                            }

                            CurrentCup = CupKind.Nothing;
                        }
                        else
                        {
                            // 決勝戦でなければ試合進行度を加算
                            GameRound++;
                        }
                    }
                    else
                    {
                        // リーグ戦
                        LeagueWin++;
                        ApplyLeagueResult();
                    }
                    break;
                case GameResultKind.Lose:
                    // 敗北
                    if (CurrentCup == CupKind.SummerPreliminary || CurrentCup == CupKind.SummerKoshien)
                    {
                        // 夏の大会であれば3年生の引退
                        Graduate();
                    }
                    Lose++;
                    LatestGameResult = GameResultKind.Lose;
                    if (CurrentCup != CupKind.AutumnPreliminary)
                    {
                        // リーグ戦以外は大会終了
                        CurrentCup = CupKind.Nothing;
                    }
                    else
                    {
                        // リーグ戦
                        ApplyLeagueResult();
                    }
                    break;
                case GameResultKind.Draw:
                    // 引き分け
                    Draw++;
                    LatestGameResult = GameResultKind.Draw;
                    if (CurrentCup != CupKind.AutumnPreliminary)
                    {
                        // リーグ戦以外の場合
                        // 試合進行度などを何も変更しないことで再試合を発生させる
                        // 同じ高校と再び対戦するようにフラグを立てる
                        IsReMatch = true;
                    }
                    else
                    {
                        // リーグ戦は引き分けでも再試合はなく、次の試合に進む(2勝以上が条件のため負けに等しい)
                        ApplyLeagueResult();
                    }
                    break;
                default:
                    throw new Exception("Invalid GameResultKind");
            }
        }