Пример #1
0
        /// Finishes the battle and grands
        /// gained exp to the surviving players
        public void finishBattle()
        {
            int exp = expPool / Participants.Where(p => p is Player).Count();

            Participants.ForEach(p => {
                p.IsFighting   = false;
                p.DeathEvent  -= onDeath;
                p.DamageEvent -= onDamage;
                p.Exp         += exp;
                p.levelUp(0.1f);
            });

            Participants.Clear();
            TurnList.Clear();
        }
Пример #2
0
        private async void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            await Task.Factory.StartNew(() =>
            {
                InvokeUI(() =>
                {
                    var nameStudent = dataGridView1.CurrentCell.RowIndex;

                    var nameTypeWorkCColumnIndex = dataGridView1.CurrentCell.ColumnIndex;

                    string typeWorkName = Convert.ToString(dataGridView1.Columns[nameTypeWorkCColumnIndex].HeaderText);

                    if (typeWorkName != "Лек." && typeWorkName != "ФИО" && typeWorkName != "Итог")
                    {
                        dataGridView1.ReadOnly        = true;
                        dataGridView2.Size            = new Size(450, 150);
                        dataGridView2.BackgroundColor = Color.FromArgb(255, 247, 101);

                        var indexColumnFIO = dataGridView2.Columns["ColumnFIODataGrid2"].Index;

                        dataGridView2.Columns[indexColumnFIO].Width = 220;

                        dataGridView2.Visible = true;

                        var _listTurn = TurnList.GetListTurn(typeWorkName, Convert.ToString(dataGridView1["columnFIO", nameStudent].Value),
                                                             DisciplineName, CpName, GroupName, TermName);

                        foreach (var item in _listTurn.AsParallel())
                        {
                            listTurn.Add(item);
                        }

                        try
                        {
                            int count    = dataGridView2.DisplayedRowCount(true);
                            int countLab = Convert.ToInt32(tbCountLab.Text);

                            for (int i = 0; i <= countLab - count - 1; i++)
                            {
                                listTurn.Add(new TurnList("", 0, Convert.ToString(dataGridView1["columnFIO", nameStudent].Value)));
                            }
                        }
                        catch { }
                    }
                });
            });
        }
        private void _BuildTurnList()
        {
            HasTurnMarker[] TurnMarkerArray = FindObjectsOfType <HasTurnMarker>();

            HasTurnMaxIndex = -1;
            foreach (HasTurnMarker turnMarker in TurnMarkerArray)
            {
                HasTurnMaxIndex++;
                IHasTurn hasTurn = turnMarker.gameObject.GetComponent <IHasTurn>();
                hasTurn.Initialise(this);
                TurnList.Add(turnMarker.gameObject.GetComponent <IHasTurn>());
                hasTurn.Index = HasTurnMaxIndex;
            }

            TurnList.Sort(new TurnSort());
            CurrentTurn = -1;
        }
Пример #4
0
        /// Evaluates the next action or in case of a
        /// player waits for the user to choose one
        /// and executes it. Shifts the turn list
        /// afterwards to the left
        public void nextTurn()
        {
            if (NextAction != null)
            {
                TurnList.First.Value.AP -= NextAction.APCost;
                NextAction.execute();
            }

            // shift turn list
            if (oldTurns > 0)
            {
                --oldTurns;
            }
            else
            {
                TurnList.AddLast(TurnList.First.Value);
            }
            TurnList.RemoveFirst();
        }
Пример #5
0
		protected virtual void Dispose(bool disposing)
		{
			// Check to see if Dispose has already been called.
			if (!this.disposed)
			{
				// If disposing equals true, dispose all managed
				// and unmanaged resources.
				if (disposing)
				{
					// Dispose managed resources.
					this._ActivePlayer = null;
					this._CardsAvailable = null;
					this._MessageRequestQueue = null;
					this._MessageResponseQueue = null;
					this._Players = null;
					this._RNG = null;
					this._Table = null;
					this._TurnsTaken = null;
				}

				// Call the appropriate methods to clean up
				// unmanaged resources here.
				// If disposing is false,
				// only the following code is executed.

				// Note disposing has been done.
				disposed = true;
			}
		}
Пример #6
0
        /// Adds passed creatures to the battle. Creatures
        /// may occour multiple times in the turn list if
        /// their agility is exceptional high relative
        /// to the other participants
        public void addToBattle(List <Creature> participants)
        {
            if (Participants != null)
            {
                participants = participants
                               .Where(c => !Participants.Contains(c))
                               .ToList();
            }

            participants.ForEach(c => {
                c.IsFighting   = true;
                c.DeathEvent  += onDeath;
                c.DamageEvent += onDamage;
                if (c is Npc)
                {
                    (c as Npc).Pathfinder.Path.Clear();
                }
                if (!c.ContainingMap.BattleMap.Participants.Contains(c))
                {
                    c.ContainingMap.BattleMap.Participants.Add(c);
                }
            });

            if (Participants != null)
            {
                Participants.AddRange(participants);
                oldTurns = TurnList.Count;
            }
            else
            {
                Participants = participants;
                TurnList     = new LinkedList <Creature>();
                oldTurns     = 0;
            }

            int i, n = 1, m = Participants.Count;

            int[] weights = new int[m];

            Participants = Participants
                           .OrderByDescending(c => c.Stats.AGI)
                           .ToList();

            for (i = 0; i < m; ++i)
            {
                weights[i] =
                    n * Participants[i].Stats.AGI
                    / Participants[m - 1].Stats.AGI;
            }

            while (m > 0)
            {
                for (i = 0; i < m; ++i)
                {
                    if (weights[i] > 0)
                    {
                        TurnList.AddLast(Participants[i]);
                        --weights[i];
                    }
                    else
                    {
                        --m;
                    }
                }
            }
        }