Пример #1
0
        public override void OnInitialise()
        {
            CollisionRules.DefaultCollisionRule = CollisionRule.NoSolver;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(1, 1, 1));

            float arenaSize   = 40f;
            var   arenaObject = CreateTestArena(arenaSize);

            cameraGameObject = new GameObject("camera");
            cameraGameObject.AddComponent(new ComponentCamera());
            cameraGameObject.Transform.SetPosition(new Vector3(0, 200, 0));
            cameraGameObject.Transform.SetLookAndUp(new Vector3(0, -1, 0), new Vector3(0, 0, 1));

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraGameObject);
            SystemCore.SetActiveCamera(cameraGameObject.GetComponent <ComponentCamera>());



            player = new GridWarrior(new Vector3(0, 5, 0));

            enemies = new List <SimpleEnemy>();
            for (int i = 0; i < 5; i++)
            {
                SpawnEnemy();
            }


            healthLabel = new Label(GUIFonts.Fonts["neuropolitical"], "Health:");

            healthLabel.SetPosition(new Vector2(GUIManager.GetFractionOfWidth(0.1f),
                                                GUIManager.GetFractionOfHeight(0.02f)));

            SystemCore.GUIManager.AddControl(healthLabel);

            killLabel = new Label(GUIFonts.Fonts["neuropolitical"], "Kills:");
            killLabel.SetPosition(new Vector2(GUIManager.GetFractionOfWidth(0.9f),
                                              GUIManager.GetFractionOfHeight(0.02f)));

            SystemCore.GUIManager.AddControl(killLabel);
            base.OnInitialise();
        }
Пример #2
0
 private void lstRank_DoubleClick(object sender, EventArgs e)
 {
     if(lstRank.SelectedIndices.Count != 1) return;
     SelectedWarrior = Warriors[lstRank.SelectedIndices[0]];
     lblWarriorName.Text = Warriors[lstRank.SelectedIndices[0]].Warrior.Name;
     lblWarriorFields.Text = "Fields: " + Warriors[lstRank.SelectedIndices[0]].OwnedCells.Count.ToString();
     lblWarriorWins.Text = "Wins: " + Warriors[lstRank.SelectedIndices[0]].Wins.ToString();
     lblWarriorLose.Text = "Lose: " + Warriors[lstRank.SelectedIndices[0]].Lose.ToString();
     pnSelectedWarrior.BackColor = Warriors[lstRank.SelectedIndices[0]].Color;
     txtWarrior.Text = Warriors[lstRank.SelectedIndices[0]].Warrior.ToString().Replace("\n", Environment.NewLine);
     lstCode.Items.Clear();
     foreach (WarriorLine w in Warriors[lstRank.SelectedIndices[0]].Warrior.CodeLines)
     {
         lstCode.Items.Add(new ListViewItem(new string[]
         {
             Enum.GetName(typeof (Instructors), w.Instructor),
             Enum.GetName(typeof (Modifiers), w.Modifier),
             AddressingModesHelper.GetString(w.AddressingMode1), w.Number1.ToString(),
             AddressingModesHelper.GetString(w.AddressingMode2), w.Number2.ToString()
         }));
     }
 }
Пример #3
0
        /// <summary>
        /// Get's called when a fight is finished
        /// </summary>
        /// <param name="won">The cell that won</param>
        /// <param name="lose">The cell that lost</param>
        private void FightCallback(Cell won, Cell lose)
        {
            FightsDone++;
            lock (_warriorLocker)
            {

                // Call's check function's to see if interval has passed
                CheckForSleeper();
                CheckForReplace();

                GridWarrior loser = lose.Owner;
                if (Statics.MainRandom.NextDouble() < Parameters.EvolverParameters.EvolutionChance)
                {
                    bool crossover = false;
                    Warrior evolveWarrior = _evolver.EvolveWarrior(won.Owner.Warrior, lose.Owner.Warrior, ref crossover);
                    GridWarrior newWarrior = new GridWarrior(
                        evolveWarrior,
                        !crossover ? ColorHelper.IncreaseColor(won.Owner.Color, Statics.MainRandom.Next(-25, 25), Statics.MainRandom.Next(-25, 25), Statics.MainRandom.Next(-25, 25)) : ColorHelper.Mix(won.Owner.Color, lose.Owner.Color));

                    Warriors.Add(newWarrior);
                    lose.ChangeOwner(newWarrior);
                }
                else
                {
                    lose.ChangeOwner(won.Owner);
                }

                if (loser.OwnedCells.Count == 0)
                {
                    Warriors.Remove(loser);
                }

            }
        }
Пример #4
0
        /// <summary>
        /// Fills the Grid with warriors random preset or newly generated warriors
        /// </summary>
        public void FillGrid()
        {
            if (!Directory.Exists("preset")) Directory.CreateDirectory("preset");
            List<Warrior> presWarriors = Directory.GetFiles("preset", "*.red").Select(Parser.WarriorFromOriginal).ToList();

            for (int y = 0; y < Size; y++)
            {
                for (int x = 0; x < Size; x++)
                {
                    Cells[y, x] = new Cell(x, y);
                    if (Statics.MainRandom.NextDouble() < Parameters.GridParameters.PresetChance && presWarriors.Count > 0)
                    {
                        GridWarrior newWarrior = new GridWarrior(presWarriors[0], Cells[y, x]);
                        Warriors.Add(newWarrior);
                        presWarriors.RemoveRange(0, 1);
                    }
                    else
                    {
                        Warrior newWarrior = Generator.GenerateRandomWarrior(
                            Parameters.MarsParameters.Type,
                            "",
                            "NetVolve",
                            Statics.MainRandom.Next(1, Parameters.MarsParameters.MaxWarriorLen),
                            true,
                            Parameters.MarsParameters.Coresize);

                        newWarrior.SetWarriorName();
                        GridWarrior newGridWarrior = new GridWarrior(newWarrior, Cells[y, x]);
                        Warriors.Add(newGridWarrior);
                    }
                }
            }
        }