Esempio n. 1
0
        public void Initialize(ref SimulationModelInfo simModel, ref Blackboard blackboard, ref SimulationEventDistributor distributor)
        {
            this.blackboard = blackboard;
            this.bbClient = new BlackboardClient();
            this.distributor = distributor;
            this.distClient = new SimulationEventDistributorClient();
            this.simModel = simModel;

            distributor.RegisterClient(ref distClient);

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "State", true, false);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, false);

            ScoringDB.Score s = new ScoringDB.Score("DEFENSE", null, null, 1000);
            s.calculateDMs = new List<string>();
            s.calculateDMs.Add("BluePlayer01");
            s.calculateDMs.Add("BluePlayer02");
            s.displayDMs = s.calculateDMs;

            
            s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.ObjectExists,"",""),
                                                  null,
                                                  -1));
            /*
            s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "Dead"),
                                                  new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  200));
            s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "PartlyFunctional"),
                                                  new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.FriendlyDM),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  -300));
            s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "Dead"),
                                                  new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  -1000));
            */

            //ScoringDB.scores["DEFENSE"] = s;

            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Esempio n. 2
0
        public static void Register(ScoreType st)
        {
            ScoringDB.Score s = new ScoringDB.Score(st.Name, new List<string>(), new List<string>(), st.Initial);
            for (int i = 0; i < st.Applies.Count; i++) s.calculateDMs.Add(st.Applies[i]);
            for (int i = 0; i < st.Viewers.Count; i++) s.displayDMs.Add(st.Viewers[i]);
            for (int i = 0; i < st.Rules.Count; i++)
            {
                string thisRuleName = st.Rules[i];
                ScoringRuleType thisRule = ScoringRules.Get(thisRuleName);
                if (ScoringDB.ConditionInfo.ConditionType.ObjectExists == thisRule.Condition.conditionType)
                {
                    for (int unitLoc = 0; unitLoc < thisRule.Unit.Region.Zone.Count; unitLoc++)
                    {
                        ScoringDB.ActorInfo.OwnerInfo unitOwnerInfo = new ScoringDB.ActorInfo.OwnerInfo(thisRule.Unit.Owner);
                        ScoringDB.ActorInfo.IdentifierInfo unitIdentifierInfo = thisRule.Unit.ID;
                        ScoringDB.ActorInfo.LocationInfo unitLocationInfo = new ScoringDB.ActorInfo.LocationInfo(thisRule.Unit.Region.Relationship, thisRule.Unit.Region.Zone[unitLoc]);
                                     ScoringDB.ConditionInfo conditionInfo = new ScoringDB.ConditionInfo(thisRule.Condition.conditionType, thisRule.Condition.oldState, thisRule.Condition.newState);
                        s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(unitOwnerInfo, unitIdentifierInfo, unitLocationInfo), conditionInfo, null,thisRule.Increment));

                    }             
                }
                else
                {
                  for(int unitLoc=0; unitLoc<thisRule.Unit.Region.Zone.Count;unitLoc++)
                    {
                      for (int objectLoc=0;objectLoc<thisRule.Unit.Region.Zone.Count;objectLoc++)
                      {
                    ScoringDB.ActorInfo.OwnerInfo unitOwnerInfo = new ScoringDB.ActorInfo.OwnerInfo(thisRule.Unit.Owner);
                    ScoringDB.ActorInfo.IdentifierInfo unitIdentifierInfo = thisRule.Unit.ID;
                    ScoringDB.ActorInfo.LocationInfo unitLocationInfo = new ScoringDB.ActorInfo.LocationInfo(thisRule.Unit.Region.Relationship, thisRule.Unit.Region.Zone[unitLoc]);
                    ScoringDB.ActorInfo.OwnerInfo objectOwnerInfo = new ScoringDB.ActorInfo.OwnerInfo(thisRule.ObjectID.Owner);
                    ScoringDB.ActorInfo.IdentifierInfo objectIdentifierInfo = thisRule.ObjectID.ID;
                    ScoringDB.ActorInfo.LocationInfo objectLocationInfo = new ScoringDB.ActorInfo.LocationInfo(thisRule.ObjectID.Region.Relationship, thisRule.ObjectID.Region.Zone[objectLoc]);
                    ScoringDB.ConditionInfo conditionInfo = new ScoringDB.ConditionInfo(thisRule.Condition.conditionType, thisRule.Condition.oldState, thisRule.Condition.newState);
                    s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(unitOwnerInfo, unitIdentifierInfo, unitLocationInfo), conditionInfo, new ScoringDB.ActorInfo(objectOwnerInfo, objectIdentifierInfo, objectLocationInfo), thisRule.Increment));
                      }
                    }             

                }
                }
            ScoringDB.scores[st.Name] = s;
        }