Exemplo 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);
        }
Exemplo n.º 2
0
    public override void AgentReset()

    {
        Vector3 randomPos = new Vector3(Random.Range(minRange, maxRange), 1f, Random.Range(minRange, maxRange));

        transform.position = randomPos + pivotTransform.position;

        transform.rotation = Quaternion.Euler(new Vector3(0, 0, 0));



        Hp = 100;

        Hungry = 100;

        Friendly = 0;



        currentAction = "Idle";

        playerRelation = PlayerRelation.Enemy;

        enterDeadZone = false;
    }
Exemplo n.º 3
0
 public void SetPlayerRelation()
 {
     if (Friendly < MaxFriendly * 0.2)
     {
         playerRelation = PlayerRelation.Enemy;
     }
     else if (Friendly < MaxFriendly * 0.5)
     {
         playerRelation = PlayerRelation.Stranger;
     }
     else if (Friendly < MaxFriendly * 0.8)
     {
         playerRelation = PlayerRelation.Friend;
     }
     else
     {
         playerRelation = PlayerRelation.Soulmate;
     }
 }
Exemplo n.º 4
0
 public void SetPlayerRelation() // TODO: Friendly 값 바뀌는 곳에 이 함수 추가하기
 {
     // TODO: playerRelation 상태 바뀌는 기준 정하기. (일단 임시로 정했음.)
     if (Friendly < MaxFriendly * 0.2)
     {
         playerRelation = PlayerRelation.Enemy;
     }
     else if (Friendly < MaxFriendly * 0.5)
     {
         playerRelation = PlayerRelation.Stranger;
     }
     else if (Friendly < MaxFriendly * 0.8)
     {
         playerRelation = PlayerRelation.Friend;
     }
     else
     {
         playerRelation = PlayerRelation.Soulmate;
     }
 }
 public SpCharacterInfo(Player player, PlayerRelation relation)
 {
     Player = player;
     Relation = relation;
 }
Exemplo n.º 6
0
 public SpCharacterRelation(Creature creature, PlayerRelation relation)
 {
     Creature = creature;
     Relation = relation;
 }
Exemplo n.º 7
0
 public SpCharacterInfo(Player player, PlayerRelation relation)
 {
     Player   = player;
     Relation = relation;
 }
Exemplo n.º 8
0
        public bool IsValid(Fleet fleet, Mappable target, EmpireData sender, EmpireData receiver)
        {
            Message message = new Message();

            Messages.Add(message);

            message.Audience = fleet.Owner;
            message.Text     = "Fleet " + fleet.Name + " has waypoint orders to invade ";

            // First check that we are actuallly in orbit around a planet.

            if (fleet.InOrbit == null || target == null || !(target is Star))
            {
                message.Text += "but the target is not a planet.";
                return(false);
            }

            // and that we have troops.

            if (fleet.Cargo.ColonistsInKilotons == 0)
            {
                message.Text += "but there are no troops on board.";
                return(false);
            }

            Star star = (Star)target;

            // Consider the diplomatic situation
            if (fleet.Owner == star.Owner)
            {
                // already own this planet, so colonists can beam down safely
                star.Colonists += fleet.Cargo.ColonistNumbers;
                fleet.Cargo.ColonistsInKilotons = 0;

                message.Text += star.Name + " but it is already ours. Troops have joined the local populace.";
                return(false);
            }

            if (star.Owner == Global.Nobody)
            {
                // This star has not been colonised. Can't invade.
                message.Text += star.Name + " but it is not colonised. You must send a ship with a colony module and orders to colonise to take this system.";
                return(false);
            }

            PlayerRelation relation = sender.EmpireReports[star.Owner].Relation;

            switch (relation)
            {
            case PlayerRelation.Friend:
            case PlayerRelation.Neutral:
            {
                message.Text += star.Name + " but the " + sender.EmpireReports[star.Owner].RaceName + " are not our enemies. Order has been cancelled.";
                return(false);
            }

            case PlayerRelation.Enemy:
            {
                // continue with the invasion
                break;
            }

            default:
            {
                Report.Error("An unrecognised relationship \"" + relation + "\" was encountered. Invasion of " + star.Name + " has been cancelled.");
                break;
            }
            }

            // check for starbase
            if (star.Starbase != null)
            {
                message.Text += star.Name + " but the starbase at " + star.Name + " would kill all invading troops. Order has been cancelled.";
                return(false);
            }

            return(true);
        }