Exemplo n.º 1
0
        public void OnPlayerUseWorldItemSecondary(object dialogResult)
        {
            WIListResult result = (WIListResult)dialogResult;

            switch (result.SecondaryResult)
            {
            case "Up":
                if (HasUpperFloor && PowerSource.HasPower && MissionCondition.CheckCondition(State.UpperFloorCondition))
                {
                    TargetElevator.SendToStopIndex(State.StopIndex + 1);
                }
                break;

            case "Down":
                if (HasLowerFloor && PowerSource.HasPower && MissionCondition.CheckCondition(State.LowerFloorCondition))
                {
                    TargetElevator.SendToStopIndex(State.StopIndex - 1);
                }
                break;

            case "Call":
                if (HasLowerFloor && PowerSource.HasPower && MissionCondition.CheckCondition(State.LowerFloorCondition))
                {
                    TargetElevator.SendToStopIndex(State.StopIndex);
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public void CheckConditions()
        {
            if (mCheckingConditions)
            {
                return;
            }

            mCheckingConditions = true;
            MissionStatesCondition topCondition = null;
            int topConditionIndex = 0;

            if (MissionCondition.CheckConditions <MissionStatesCondition> (State.Conditions, out topConditionIndex))
            {
                topCondition = State.Conditions [topConditionIndex];
                if (topCondition.RemoveFromGame)
                {
                    worlditem.SetMode(WIMode.RemovedFromGame);
                }
                else
                {
                    if (topCondition.ExistingState == worlditem.State)
                    {
                        worlditem.State = topCondition.StateVariable;
                    }
                }
            }

            mCheckingConditions = false;
        }
Exemplo n.º 3
0
        public static bool CheckConditions <T> (List <T> conditions, out int topCondition) where T : MissionCondition
        {
            topCondition = -1;
            int topPriority = -1;

            //check conditions from bottom to top
            for (int i = conditions.LastIndex(); i >= 0; i--)
            {
                MissionCondition condition = conditions [i];

                if (topPriority >= 0)
                {
                    if (condition.Priority < topPriority)
                    {
                        //don't bother if this condition is outranked
                        continue;
                    }
                }

                if (CheckCondition(condition))
                {
                    topCondition = i;
                }
            }
            return(topCondition >= 0);
        }
Exemplo n.º 4
0
        public MissionInteriorCondition GetTopCondition()
        {
            int topConditionIndex = 0;
            MissionInteriorCondition topCondition = null;

            if (MissionCondition.CheckConditions <MissionInteriorCondition>(State.Conditions, out topConditionIndex))
            {
                topCondition = State.Conditions[topConditionIndex];
            }
            else
            {
                topCondition = State.Default;
            }
            return(topCondition);
        }
        protected IEnumerator CheckConditionOverTime()
        {
            //wait for a second because missions may need to update in response to leaving this location
            double waitUntil = Frontiers.WorldClock.AdjustedRealTime + 2.5f;

            while (Frontiers.WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }
            //see if our mission conditions are met
            if (MissionCondition.CheckCondition(State.Condition))
            {
                //create a spawner that follows the player around
                //this will ensure that even if the location is unloaded
                //the character will still be spawned
                Player.Local.CharacterSpawner.AddSpawnRequest(State.Request);
                if (State.FinishOnSpawn)
                {
                    Finish();
                }
            }
            mCheckingConditionOverTime = false;
            yield break;
        }
Exemplo n.º 6
0
        public override void PopulateOptionsList(List <WIListOption> options, List <string> message)
        {
            if (!FindElevator())
            {
                return;
            }

            if (gElevatorUpOption == null)
            {
                gElevatorUpOption = new WIListOption("Elevator Up", "Up");
                //gElevatorUpOption.ObexFont = true;

                gElevatorDownOption = new WIListOption("Elevator Down", "Up");
                //gElevatorDownOption.ObexFont = true;

                gElevatorCallOption = new WIListOption("Call Elevator", "Call");
                //gElevatorCallOption.ObexFont = true;
            }

            if (HasUpperFloor)
            {
                gElevatorUpOption.Disabled = !(PowerSource.HasPower && TargetElevator.PlayerIsOnElevator && MissionCondition.CheckCondition(State.UpperFloorCondition));
                options.Add(gElevatorUpOption);
                if (gElevatorUpOption.Disabled)
                {
                    Debug.Log("upper disabled. has power? " + PowerSource.HasPower.ToString() + " player on elevator? " + TargetElevator.PlayerIsOnElevator.ToString() + " condition? " + MissionCondition.CheckCondition(State.UpperFloorCondition).ToString() + " " + State.StopIndex.ToString());
                }
            }
            if (HasLowerFloor)
            {
                gElevatorDownOption.Disabled = !(PowerSource.HasPower && !TargetElevator.PlayerIsOnElevator && !MissionCondition.CheckCondition(State.LowerFloorCondition));
                options.Add(gElevatorDownOption);
                if (gElevatorDownOption.Disabled)
                {
                    Debug.Log("lower disabled. has power? " + PowerSource.HasPower.ToString() + " player on elevator? " + TargetElevator.PlayerIsOnElevator.ToString() + " condition? " + MissionCondition.CheckCondition(State.LowerFloorCondition).ToString() + " " + State.StopIndex.ToString());
                }
            }
            gElevatorCallOption.Disabled = !(PowerSource.HasPower && TargetElevator.CurrentStopIndex != State.StopIndex && MissionCondition.CheckCondition(State.CallElevatorCondition) && !TargetElevator.PlayerIsOnElevator);
            if (gElevatorCallOption.Disabled)
            {
                Debug.Log("call disabled. has power? " + PowerSource.HasPower.ToString() + " already on floor? " + (TargetElevator.CurrentStopIndex == State.StopIndex).ToString() + " condition? " + MissionCondition.CheckCondition(State.CallElevatorCondition).ToString() + " " + State.StopIndex.ToString());
            }
            options.Add(gElevatorCallOption);

            gElevatorUpOption.Disabled   = false;
            gElevatorDownOption.Disabled = false;
            gElevatorCallOption.Disabled = false;
        }
Exemplo n.º 7
0
        public static bool CheckCondition(MissionCondition condition)
        {
            if (condition == null || condition.IsEmpty)
            {
                return(true);
            }

            bool missionObtains   = true;
            bool objectiveObtains = true;
            bool variableObtains  = true;

            MissionStatus missionStatus = MissionStatus.Dormant;

            //always check mission state regardless
            if (Missions.Get.MissionStatusByName(condition.MissionName, ref missionStatus))
            {
                missionObtains = Flags.Check((uint)missionStatus, (uint)condition.Status, Flags.CheckType.MatchAny);
                //only check second mission if the operator is set to something
                if (condition.CheckSecondMission)
                {
                    bool secondMissionObtains = true;
                    if (Missions.Get.MissionStatusByName(condition.SecondMissionName, ref missionStatus))
                    {
                        secondMissionObtains = Flags.Check((uint)missionStatus, (uint)condition.SecondMissionStatus, Flags.CheckType.MatchAny);
                    }
                    //now combine mission obtains and second mission obtains by operation type
                    switch (condition.SecondMissionOperator)
                    {
                    case MissionStatusOperator.And:
                    default:
                        missionObtains = missionObtains & secondMissionObtains;
                        break;

                    case MissionStatusOperator.Or:
                        missionObtains = missionObtains | secondMissionObtains;
                        break;

                    case MissionStatusOperator.Not:
                        missionObtains = missionObtains & (!secondMissionObtains);
                        break;
                    }
                }
            }
            //if we're still good after checking the missions, move forward
            if (missionObtains && condition.CheckObjective)
            {
                MissionStatus objectiveStatus = MissionStatus.Dormant;
                if (Missions.Get.ObjectiveStatusByName(condition.MissionName, condition.ObjectiveName, ref objectiveStatus))
                {
                    objectiveObtains = Flags.Check((uint)objectiveStatus, (uint)condition.ObjectiveStatus, Flags.CheckType.MatchAny);
                    //only check second objective if the operator is set to something
                    if (condition.CheckSecondObjective)
                    {
                        bool secondObjectiveObtains = true;
                        if (Missions.Get.ObjectiveStatusByName(condition.MissionName, condition.SecondObjectiveName, ref objectiveStatus))
                        {
                            secondObjectiveObtains = Flags.Check((uint)objectiveStatus, (uint)condition.SecondObjectiveStatus, Flags.CheckType.MatchAny);
                        }
                        //now combine mission obtains and second mission obtains by operation type
                        switch (condition.SecondObjectiveOperator)
                        {
                        case MissionStatusOperator.And:
                        default:
                            missionObtains = objectiveObtains & secondObjectiveObtains;
                            break;

                        case MissionStatusOperator.Or:
                            missionObtains = objectiveObtains | secondObjectiveObtains;
                            break;

                        case MissionStatusOperator.Not:
                            missionObtains = objectiveObtains & (!secondObjectiveObtains);
                            break;
                        }
                    }
                }
            }

            return(missionObtains & objectiveObtains & variableObtains);
        }