示例#1
0
        public object Clone()
        {
            SlimFriendly Cannon = new SlimFriendly(this.UID);

            Cannon.Targets = new int[this.Targets.Length];
            Buffer.BlockCopy(this.Targets, 0, Cannon.Targets, 0, sizeof(int) * this.Targets.Length);

            return(Cannon);
        }
示例#2
0
        public int Fire(CSimpleArtillary ActualTargets, SlimEnemy SlimEnemy, SlimFriendly Cannon)
        {
            int IsEnemyDead = 0;

            if (Cannon.Targets.Length > Cannon.ShotsTaken)
            {
                if (SlimEnemy.Health > 0 && this.CheckFireConstraints(ActualTargets))
                {
                    SlimEnemy.Health -= this.Damage;
                    SlimEnemy.HittedBy.Add(this.UID);

                    if (SlimEnemy.Health <= 0)
                    {
                        IsEnemyDead = 1;
                    }
                }

                Cannon.ShotsTaken++;
            }

            return(IsEnemyDead);
        }
示例#3
0
        protected override void DeadFitness()
        {
            CSimpleArtillary FCannon;
            List <ISlim>     remains = this.Genes.Select(x => x).ToList();

            while (remains.Count > 0)
            {
                for (int i = 0; i < remains.Count; i++)
                {
                    SlimFriendly SCannon = (SlimFriendly)remains[i];
                    FCannon         = CStrategyPool.ActiveStrategy.FriendliesData[SCannon.UID];
                    this.DeadCount += FCannon
                                      .Fire(CStrategyPool.ActiveStrategy.EnemiesData[SCannon.Targets[SCannon.ShotsTaken]], this.Enemies[SCannon.Targets[SCannon.ShotsTaken]], SCannon);

                    if (SCannon.ShotsTaken == FCannon.Ammunition)
                    {
                        remains.RemoveAt(i);
                        i--;
                    }
                }
            }
        }