コード例 #1
0
        private int GetShotCount(bool isOpponentAttack)
        {
            int shotCount = 0;

            myShots.ForEach(r =>
            {
                DbAttack attack = DbManager.Instance.GameDbManager.GetAttackById(r.AttackId);
                if (attack.IsOpponentAttack == isOpponentAttack)
                {
                    shotCount += r.Count;
                }
            });
            return(shotCount + GetGoalCount(isOpponentAttack));
        }
コード例 #2
0
        private int GetReboundCount(bool isOpponentAttack)
        {
            int reboundCount = 0;

            myRebounds.ForEach(r =>
            {
                DbAttack attack = DbManager.Instance.GameDbManager.GetAttackById(r.AttackId);
                if (attack.IsOpponentAttack == isOpponentAttack)
                {
                    reboundCount += r.Count;
                }
            });
            return(reboundCount);
        }
コード例 #3
0
        private void SetFormation()
        {
            DbAttack lastAttack = myGameDbManager.GetLastAttackOfGame(Game.Id);

            if (lastAttack == null) // start game
            {
                StartingFunction = Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence;
                CurrentFunction  = Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence;
            }
            else
            {
                bool isGameH1 = Game.Status == "H1";
                if (lastAttack.IsFirstHalf == isGameH1)
                {
                    // half is started
                    StartingFunction = lastAttack.ZoneStartFunction == "A" ? EZoneFunction.Attack : EZoneFunction.Defence;
                    CurrentFunction  = lastAttack.IsOpponentAttack ? EZoneFunction.Defence : EZoneFunction.Attack;
                    ChangeFunction(lastAttack.GoalId != null);
                }
                else
                {
                    // start H2
                    string lastDefendingZone = "";
                    if (lastAttack.IsOpponentAttack)
                    {
                        lastDefendingZone = lastAttack.ZoneStartFunction == "A" ? "A" : "D";
                    }
                    else
                    {
                        lastDefendingZone = lastAttack.ZoneStartFunction == "A" ? "D" : "A";
                    }

                    StartingFunction = lastAttack.ZoneStartFunction == "A" ? EZoneFunction.Attack : EZoneFunction.Defence;
                    CurrentFunction  = lastAttack.IsOpponentAttack ? EZoneFunction.Defence : EZoneFunction.Attack;
                    ChangeFunction(lastAttack.GoalId != null);

                    var newCurrentFunction = !Game.IsHome ? EZoneFunction.Attack : EZoneFunction.Defence;
                    if (newCurrentFunction != CurrentFunction)
                    {
                        StartingFunction = StartingFunction == EZoneFunction.Attack ? EZoneFunction.Defence : EZoneFunction.Attack;
                    }
                    CurrentFunction = newCurrentFunction;
                    Init();
                }
            }
            CurrentAttack = new Attack(CurrentFunction, StartingFunction, Game.Id, true);
        }
コード例 #4
0
        private int GetAssitCount(bool isOpponent)
        {
            int assistCount = 0;

            myAssist.ForEach(g =>
            {
                DbAttack attack = myAttacks.FirstOrDefault(a =>
                {
                    if (!a.GoalId.HasValue)
                    {
                        return(false);
                    }
                    return(a.GoalId.Value == g.Id);
                });
                if (attack.IsOpponentAttack == isOpponent)
                {
                    assistCount++;
                }
            });
            return(assistCount);
        }