Esempio n. 1
0
        public override ProgrammingElement Clone()
        {
            CreatableModifier clone = new CreatableModifier(CreatableId, label);

            CopyTo(clone);
            return(clone);
        }
Esempio n. 2
0
 protected void CopyTo(CreatableModifier clone)
 {
     base.CopyTo(clone);
     // do not assign creatableId field here. it is passed in the constructor.
 }
Esempio n. 3
0
        }   // end of PrintTaskProgramming()

        static private string GetTileString(Reflex reflex)
        {
            string tiles = "";

            // Ad blanks at beginning for indentation level.
            for (int i = 0; i < reflex.Indentation; i++)
            {
                tiles += "    ";
            }

            tiles += Strings.Localize("programming.when") + " ";

            if (reflex.Data.Sensor != null)
            {
                tiles += reflex.Data.Sensor.label + " ";
            }
            else
            {
                tiles += "always ";
            }

            for (int i = 0; i < reflex.Data.Filters.Count; i++)
            {
                ScoreFilter sf = reflex.Data.Filters[i] as ScoreFilter;
                if (sf != null)
                {
                    tiles += sf.points.ToString() + " ";
                }
                tiles += reflex.Data.Filters[i].label + " ";

                TerrainFilter tf = reflex.Data.Filters[i] as TerrainFilter;
                if (tf != null)
                {
                    ushort matIdx   = (ushort)reflex.MaterialType;
                    int    matLabel = Terrain.MaterialIndexToLabel(matIdx);
                    tiles += matLabel.ToString() + " ";
                }

                TimerFilter tif = reflex.Data.Filters[i] as TimerFilter;
                if (tif != null)
                {
                    tiles += tif.seconds.ToString() + " ";
                }
            }

            tiles += "-- " + Strings.Localize("programming.do") + " ";

            if (reflex.Data.Actuator != null)
            {
                tiles += reflex.Data.Actuator.label + " ";
            }

            if (reflex.Data.Selector != null)
            {
                tiles += reflex.Data.Selector.label + " ";
            }

            for (int i = 0; i < reflex.Data.Modifiers.Count; i++)
            {
                ScoreModifier sm = reflex.Data.Modifiers[i] as ScoreModifier;
                if (sm != null)
                {
                    tiles += sm.points.ToString() + " ";
                }

                CreatableModifier cm = reflex.Data.Modifiers[i] as CreatableModifier;
                if (cm != null)
                {
                    GameActor actor = InGame.inGame.GetCreatable(cm.CreatableId);
                    if (actor != null)
                    {
                        tiles += actor.DisplayNameNumber + " ";
                    }
                    else
                    {
                        tiles += "? ";
                    }
                }
                else
                {
                    tiles += reflex.Data.Modifiers[i].label + " ";
                }
            }

            return(tiles);
        }   // end of GetTileString()
Esempio n. 4
0
        }                  // end of PrintTaskProgramming()

        static private string SerializeTileString(Reflex reflex)
        {
            string tiles = "{'when':{";

            if (reflex.Data.Sensor != null)
            {
                tiles += "'sensor':'" + reflex.Data.Sensor.label + "',";
                if (reflex.Data.Sensor.label == "hear")    //if this is a hear sensor.
                {
                    for (int i = 0; i < reflex.Data.Filters.Count; i++)
                    {
                        if (reflex.Data.Filters[i].label == "said")//see if there is a specific hear text.
                        {
                            tiles += "'hearText':[";
                            for (int j = 0; j < reflex.SaidStrings.Count; j++)
                            {
                                tiles += "'" + reflex.SaidStrings[j] + "',";
                            }
                            tiles += "],";
                        }
                    }
                }
            }
            else
            {
                tiles += "'sensor':" + "'always',";
            }

            tiles += "'filters':[";
            for (int i = 0; i < reflex.Data.Filters.Count; i++)
            {
                ScoreFilter sf = reflex.Data.Filters[i] as ScoreFilter;
                if (sf != null)
                {
                    tiles += "'" + sf.points.ToString() + "',";
                }
                tiles += "'" + reflex.Data.Filters[i].label + "',";

                TerrainFilter tf = reflex.Data.Filters[i] as TerrainFilter;
                if (tf != null)
                {
                    ushort matIdx   = (ushort)reflex.MaterialType;
                    int    matLabel = Terrain.MaterialIndexToLabel(matIdx);
                    tiles += "'" + matLabel.ToString() + "',";
                }
            }
            tiles += "]";  //filters
            tiles += "},"; //when

            tiles += "'do':{";

            if (reflex.Data.Actuator != null)
            {
                tiles += "'action':'" + reflex.Data.Actuator.label + "',";
                // If we have a say verb, also output the text.
                if (reflex.Data.Actuator.upid == "actuator.say")
                {
                    tiles += "'sayText':[";
                    for (int j = 0; j < reflex.SayStrings.Count; j++)
                    {
                        tiles += "'" + reflex.SayStrings[j] + "',";
                    }
                    tiles += "],";
                }
            }
            if (reflex.Data.Selector != null)
            {
                tiles += "'selector':'" + reflex.Data.Selector.label + "',";
            }

            tiles += "'modifiers':[";
            for (int i = 0; i < reflex.Data.Modifiers.Count; i++)
            {
                ScoreModifier sm = reflex.Data.Modifiers[i] as ScoreModifier;
                if (sm != null)
                {
                    tiles += "points:" + sm.points.ToString() + ",";
                }

                CreatableModifier cm = reflex.Data.Modifiers[i] as CreatableModifier;
                if (cm != null)
                {
                    GameActor actor = InGame.inGame.GetCreatable(cm.CreatableId);
                    if (actor != null)
                    {
                        tiles += "actorName:" + actor.DisplayNameNumber + ",";
                    }
                    else
                    {
                        tiles += "<unknown>";
                    }
                }
                else
                {
                    tiles += "'" + reflex.Data.Modifiers[i].label + "',";
                }
            }
            tiles += "]";  //modifiers
            tiles += "}";  //do
            tiles += "},"; //line
            return(tiles);
        }                  // end of GetTileString()