Esempio n. 1
0
        public override void Effect(ActionTakerMythObject taker)
        {
            if (taker.CurrentGoal == ActionGoal.CreatePlane)
            {
                taker.CreatedPlane         = new Plane();
                taker.CreatedPlane.Creator = taker;

                if (CreationMythState.Planes.Count == 0)
                {
                    taker.CreatedPlane.Tag = Constants.SpecialTags.CORE_WORLD_TAG;
                }

                if (CreationMythState.Planes.Count == 1)
                {
                    taker.CreatedPlane.Tag = Constants.SpecialTags.TRAVEL_DIMENSION_TAG;
                }
            }
            else if (taker.CurrentGoal == ActionGoal.CreateSapientSpecies)
            {
                taker.CreatedSapientSpecies         = new SapientSpecies();
                taker.CreatedSapientSpecies.Creator = taker;
            }
            else if (taker.CurrentGoal == ActionGoal.CreateDeity)
            {
                taker.CreadedDeity         = new Deity();
                taker.CreadedDeity.Creator = taker;
            }
        }
Esempio n. 2
0
        public override void Effect(ActionTakerMythObject taker)
        {
            if (taker.CreatedPlane.Tag == Constants.SpecialTags.CORE_WORLD_TAG)
            {
                taker.CreatedPlane.PlaneSize = Program.DataLoadHandler.PlaneSizes[Program.DataLoadHandler.PlaneSizes.Count - 1];
                return;
            }


            int total_spawn_weight = 0;

            foreach (PlaneSize s in Program.DataLoadHandler.PlaneSizes)
            {
                total_spawn_weight = total_spawn_weight + s.SpawnWeight;
            }

            int chance         = ConfigValues.Random.Next(total_spawn_weight);
            int prev_weight    = 0;
            int current_weight = 0;

            foreach (PlaneSize s in Program.DataLoadHandler.PlaneSizes)
            {
                current_weight = current_weight + s.SpawnWeight;
                if (prev_weight <= chance && chance < current_weight)
                {
                    taker.CreatedPlane.PlaneSize = s;
                }

                prev_weight = current_weight;
            }
        }
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            int unique_categories = 0, traits_of_unique_categories = 0;

            foreach (var category in Program.DataLoadHandler.TraitCategories)
            {
                if (category.Unique)
                {
                    unique_categories += 1;
                    foreach (SpeciesTrait trait in taker.CreatedSapientSpecies.Traits)
                    {
                        if (trait.Category == category.Tag)
                        {
                            traits_of_unique_categories += 1;
                        }
                    }
                }
            }

            if (unique_categories == traits_of_unique_categories)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        public override void Effect(ActionTakerMythObject taker)
        {
            if (taker.CreatedPlane.Tag == SpecialTags.TRAVEL_DIMENSION_TAG)
            {
                taker.CreatedPlane.PlaneElement = Program.DataLoadHandler.SearchElement("air");
                return;
            }

            List <PlaneElement> elements = Program.DataLoadHandler.PlaneElements;
            int plane_element_count      = elements.Count;

            int[] spawn_weights      = new int[plane_element_count];
            int   total_spawn_weight = 0;

            int count = 0;

            foreach (PlaneElement element in elements)
            {
                spawn_weights[count] = element.SpawnWeight;
                total_spawn_weight   = total_spawn_weight + element.SpawnWeight;
                count++;
            }

            if (total_spawn_weight == 0)
            {
                total_spawn_weight += 1;
                spawn_weights[0]    = 1;
            }


            int chance = ConfigValues.Random.Next(total_spawn_weight);
            int prev_weight = 0, current_weight = 0;

            for (int i = 0; i < plane_element_count; i++)
            {
                current_weight += spawn_weights[i];
                if (prev_weight <= chance && chance < current_weight)
                {
                    taker.CreatedPlane.PlaneElement = elements[i];
                }
                prev_weight = current_weight;
            }

            for (int i = 0; i < plane_element_count; i++)
            {
                if (elements[i] == taker.CreatedPlane.PlaneElement)
                {
                    elements[i].SpawnWeight = spawn_weights[i] - 5;
                }
                else if (elements[i].Opposite == taker.CreatedPlane.PlaneElement.Tag)
                {
                    elements[i].SpawnWeight = spawn_weights[i] + 100;
                }
                else
                {
                    elements[i].SpawnWeight = spawn_weights[i] + 5;
                }
            }
        }
        public override void Effect(ActionTakerMythObject taker)
        {
            TreeNode <CreationTreeNode> species_node = CreationMythState.CreationTree.TreeRoot.searchNode(searchPlaneNode, new CreationTreeNode(taker));

            if (species_node.Parent.Value.Character == "p")
            {
                taker.CreatedSapientSpecies.NativePlane = (Plane)species_node.Parent.Value.MythObject;
            }
        }
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     if (taker.CreatedSapientSpecies.Traits.Count < 3)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 static public void UpdateActionLog(ActionTakerMythObject myth_object, bool action_finished)
 {
     if (myth_object.CurrentAction == null)
     {
         _action_log.Add(myth_object.Name + " has reached the following goal: " + myth_object.CurrentGoal.ToString());
     }
     else
     {
         _action_log.Add(myth_object.Name + " has taken " + myth_object.CurrentAction.ToString() + " and reached: " + myth_object.CurrentGoal.ToString());
     }
 }
Esempio n. 8
0
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     if (taker.CreatedPlane.PlaneType.HasDominantElement)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public override void Effect(ActionTakerMythObject taker)
 {
     if (taker.CurrentGoal == ActionGoal.CreatePlane)
     {
         taker.CreatedPlane.Name = "Plane " + taker.CreatedPlane.Identifier;
     }
     else if (taker.CurrentGoal == ActionGoal.CreateDeity)
     {
         taker.CreadedDeity.Name = "Deity " + taker.CreadedDeity.Identifier;
     }
 }
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     if (taker.CurrentGoal == ActionGoal.CreatePlane)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 11
0
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     if (taker.CreadedDeity.Domains.Count > 5)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     // In case of the core world it cannot be connected with anything as no other plane exists yet.
     if (CreationMythState.Planes.Count <= 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 13
0
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            if (!(taker.CurrentGoal == ActionGoal.CreateDeity))
            {
                return(false);
            }

            if (taker.CreadedDeity.Domains.Count > 0)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 14
0
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            if (CreationMythState.Planes.Count <= 0)
            {
                return(false);
            }

            // Do not take any ethereal planes
            if (taker.CreatedPlane.PlaneSize == null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 15
0
 public override void Effect(ActionTakerMythObject taker)
 {
     if (taker.CreatedPlane.Tag == Constants.SpecialTags.TRAVEL_DIMENSION_TAG)
     {
         taker.CreatedPlane.connectPlane(CreationMythState.Planes[0]);
     }
     else
     {
         Plane temp = CreationMythState.Planes[ConfigValues.Random.Next(CreationMythState.Planes.Count)];
         while (temp.MaxConnectionsReached() || !temp.IsNotConnectedTo(taker.CreatedPlane))
         {
             temp = CreationMythState.Planes[ConfigValues.Random.Next(CreationMythState.Planes.Count)];
         }
         taker.CreatedPlane.connectPlane(temp);
     }
 }
Esempio n. 16
0
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            if (CreationMythState.Planes.Count <= 0)
            {
                return(false);
            }

            if (taker.CreatedPlane.PlaneType.IsIntegrated != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 17
0
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            if (taker.CreatedPlane.PlaneType == null)
            {
                return(false);
            }

            if (taker.CreatedPlane.PlaneType.IsIntegrated == null)
            {
                return(true);
            }
            else
            {
                return(false);
            };
        }
Esempio n. 18
0
 public override void Effect(ActionTakerMythObject taker)
 {
     if (taker.CreatedPlane.Tag == SpecialTags.TRAVEL_DIMENSION_TAG)
     {
         taker.CreatedPlane.connectPlane(searchPlaneTag(SpecialTags.CORE_WORLD_TAG));
     }
     else if (taker.CreatedPlane.PlaneSize.MaxNeighbours <= 1)
     {
         taker.CreatedPlane.connectPlane(searchPlaneSize("large"));
     }
     else
     {
         // Connect every plane with the travel dimension.
         taker.CreatedPlane.connectPlane(searchPlaneTag(SpecialTags.TRAVEL_DIMENSION_TAG));
     }
 }
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            int total_value_spent = 0;

            foreach (CivilizationEthos ethos in taker.CreatedCivilisation.Ethos)
            {
                total_value_spent += ethos.Strength;
            }

            if (total_value_spent <= 8)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 20
0
        public override bool checkPrecondition(ActionTakerMythObject taker)
        {
            if (CreationMythState.Planes.Count <= 1)
            {
                return(false);
            }

            if (taker.CreatedPlane.MaxConnectionsReached())
            {
                return(false);
            }

            if (taker.CreatedPlane.NeighbourPlanes.Count >= CreationMythState.Planes.Count)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 21
0
        public override void Effect(ActionTakerMythObject taker)
        {
            if (taker.CurrentGoal == ActionGoal.CreatePlane)
            {
                CreationMythState.MythObjects.Add(taker.CreatedPlane);
                CreationMythState.Planes.Add(taker.CreatedPlane);
                CreationMythState.CreationTree.TreeRoot.traverseTree(addPlaneToCreationTree, new CreationTreeNode(taker));
            }
            else if (taker.CurrentGoal == ActionGoal.CreateDeity)
            {
                CreationMythState.ActionableMythObjects.Enqueue(taker.CreadedDeity);
                CreationMythState.MythObjects.Add(taker.CreadedDeity);
                CreationMythState.Deities.Add(taker.CreadedDeity);
                CreationMythState.CreationTree.TreeRoot.traverseTree(addDeityToCreationTree, new CreationTreeNode(taker));
            }

            taker.CurrentGoal = ActionGoal.None;
            CreationMythLogger.UpdateActionLog(taker, true);
        }
        public override void Effect(ActionTakerMythObject taker)
        {
            CivilizationEthos temp = Program.DataLoadHandler.CivilizationEthos[ConfigValues.Random.Next(Program.DataLoadHandler.CivilizationEthos.Count)];

            foreach (CivilizationEthos ethos in taker.CreatedCivilisation.Ethos)
            {
                if (temp.Tag == ethos.Opposite)
                {
                    return;
                }

                if (temp.Tag == ethos.Tag)
                {
                    ethos.Strength += 1;
                    return;
                }
            }

            temp.Strength = ConfigValues.Random.Next(1, 5);
            taker.CreatedCivilisation.Ethos.Add(temp);
        }
        public void Advance(S next_state, ActionTakerMythObject taker)
        {
            StateTransition <S> temp_state_transition = new StateTransition <S>(currentState, next_state);

            System.Delegate temp_delegate;
            if (TransitionTable.TryGetValue(temp_state_transition, out temp_delegate))
            {
                if (temp_delegate != null)
                {
                    StateHandler call = temp_delegate as StateHandler;
                    call(taker);
                }

                previousState = currentState;
                currentState  = next_state;
            }
            else
            {
                throw new FiniteStateMachineException();
            }
        }
Esempio n. 24
0
 public override void Effect(ActionTakerMythObject taker)
 {
     // WAIT
 }
Esempio n. 25
0
 public override bool checkPrecondition(ActionTakerMythObject taker)
 {
     return(true);
 }
Esempio n. 26
0
 protected override void AdjustWeight(ActionTakerMythObject taker)
 {
     _weight = 0;
 }
 public override void Effect(ActionTakerMythObject taker)
 {
     throw new NotImplementedException();
 }
Esempio n. 28
0
 abstract public bool checkPrecondition(ActionTakerMythObject taker);
Esempio n. 29
0
 public int getWeight(ActionTakerMythObject taker)
 {
     AdjustWeight(taker);
     return(_weight > 0 ? _weight : 0);
 }
Esempio n. 30
0
 virtual protected void AdjustWeight(ActionTakerMythObject taker)
 {
     _weight = 10;
 }