Ejemplo n.º 1
0
        /// <summary>
        /// Determine if one stack is a potential target of the other. This depends not
        /// just on the relation (friend, enemy, etc.) but also on the battle plan of
        /// the "wolf" stack (e.g. attack everyone, attack enemies, etc.).
        /// </summary>
        /// <param name="wolf">Potential attacker.</param>
        /// <param name="lamb">Potential target.</param>
        /// <returns>True if lamb is a valid target for wolf.</returns>
        public bool AreEnemies(Fleet wolf, Fleet lamb)
        {
            if (wolf.Owner == lamb.Owner)
            {
                return(false);
            }

            EmpireData     wolfData     = serverState.AllEmpires[wolf.Owner];
            PlayerRelation lambRelation = wolfData.EmpireReports[lamb.Owner].Relation;

            BattlePlan battlePlan = wolfData.BattlePlans[wolf.BattlePlan];

            if (battlePlan.Attack == "Everyone")
            {
                return(true);
            }
            else if (battlePlan.TargetId == lamb.Owner)
            {
                return(true);
            }
            else if (battlePlan.Attack == "Enemies" && lambRelation == PlayerRelation.Enemy)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// ----------------------------------------------------------------------------
        /// <Summary>
        /// Update the details of the selected plan
        /// </Summary>
        /// ----------------------------------------------------------------------------
        private void UpdatePlanDetails()
        {
            string     selection = this.planList.SelectedItem as string;
            BattlePlan plan      = battlePlans[selection];

            this.planName.Text        = plan.Name;
            this.primaryTarget.Text   = plan.PrimaryTarget;
            this.secondaryTarget.Text = plan.SecondaryTarget;
            this.tactic.Text          = plan.Tactic;
            this.attack.Text          = plan.Attack;
        }
    public void Attack()
    {
        var battlePlan = new BattlePlan
        {
            ExecutePuppyAttack  = e => e.Bite(_puppiesMustBark),
            ExecutePigeonAttack = e => e.Bombard(_pigeonAltitude)
        };
        var animals = new List <Animal>
        {
            new Puppy(),
            new Pigeon()
        };

        foreach (var animal in animals)
        {
            animal.Attack(battlePlan);
        }
    }
 public override void Attack(BattlePlan battlePlan)
 {
     battlePlan.ExecutePigeonAttack(this);
 }
 public abstract void Attack(BattlePlan battlePlan);