Ejemplo n.º 1
0
        private void InitGameAttributes()
        {
            GameAttributes.Add(Attributes.Ticks, 0);
            GameAttributes.Add(Attributes.Rank, 0);
            GameAttributes.Add(Attributes.Coal, 0);
            GameAttributes.Add(Attributes.Electricity, 0);
            GameAttributes.Add(Attributes.PopSize, 0);

            GameAttributes.Add(Attributes.Power, 0);

            GameAttributes.Add(Attributes.Size, 0);
            GameAttributes.Add(Attributes.SightRadius, 0);
            GameAttributes.Add(Attributes.Armour, 0);
            GameAttributes.Add(Attributes.Hitpoints, 0);
            GameAttributes.Add(Attributes.LandSpeed, 0);
            GameAttributes.Add(Attributes.WaterSpeed, 0);
            GameAttributes.Add(Attributes.AirSpeed, 0);
            GameAttributes.Add(Attributes.MeleeDamage, 0);

            GameAttributes.Add(Attributes.Range2Damage, 0);
            GameAttributes.Add(Attributes.Range2Max, 0);
            GameAttributes.Add(Attributes.Range2Type, 0);
            GameAttributes.Add(Attributes.Range2Special, 0);
            GameAttributes.Add(Attributes.Melee2Type, 0);

            GameAttributes.Add(Attributes.Range3Damage, 0);
            GameAttributes.Add(Attributes.Range3Max, 0);
            GameAttributes.Add(Attributes.Range3Type, 0);
            GameAttributes.Add(Attributes.Range3Special, 0);
            GameAttributes.Add(Attributes.Melee3Type, 0);

            GameAttributes.Add(Attributes.Range4Damage, 0);
            GameAttributes.Add(Attributes.Range4Max, 0);
            GameAttributes.Add(Attributes.Range4Type, 0);
            GameAttributes.Add(Attributes.Range4Special, 0);
            GameAttributes.Add(Attributes.Melee4Type, 0);

            GameAttributes.Add(Attributes.Range5Damage, 0);
            GameAttributes.Add(Attributes.Range5Max, 0);
            GameAttributes.Add(Attributes.Range5Type, 0);
            GameAttributes.Add(Attributes.Range5Special, 0);
            GameAttributes.Add(Attributes.Melee5Type, 0);

            GameAttributes.Add(Attributes.Range8Damage, 0);
            GameAttributes.Add(Attributes.Range8Max, 0);
            GameAttributes.Add(Attributes.Range8Type, 0);
            GameAttributes.Add(Attributes.Range8Special, 0);
            GameAttributes.Add(Attributes.Melee8Type, 0);

            GameAttributes.Add(Attributes.IsLand, 0);
            GameAttributes.Add(Attributes.IsSwimmer, 0);
            GameAttributes.Add(Attributes.IsFlyer, 0);

            foreach (string ability in AbilityNames.Abilities)
            {
                GameAttributes.Add(ability, 0);
            }

            GameAttributes.Add("damage", 0);
        }
Ejemplo n.º 2
0
        public void AddGame(PartialDefinition partial)
        {
            object baseObj = globalEnvironment.LookupSymbol(partial.BaseName);

            if (baseObj == null)
            {
                throw new Exception("Specified base game is unknown: " + partial.BaseName);
            }
            if (!(baseObj is Type))
            {
                throw new Exception("Specified base game is not of correct type: " + partial.BaseName);
            }
            Type baseGameType = (Type)baseObj;

            if (!baseGameType.IsSubclassOf(typeof(Game)))
            {
                throw new Exception("Specified base game is not of correct type: " + partial.BaseName);
            }
            Type newGameType = classFactory.CreateGameWrapper(moduleBuilder, baseGameType, partial);

            object[]      attrobjs          = baseGameType.GetCustomAttributes(typeof(GameAttribute), false);
            GameAttribute baseGameAttribute = (GameAttribute)attrobjs[0];

            int[] geometryParameters = baseGameAttribute.GeometryParameters;
            if (geometryParameters.Length == 0)
            {
                geometryParameters = new int[] { (int)(partial.VariableAssignments["NumFiles"]), (int)(partial.VariableAssignments["NumRanks"]) }
            }
            ;
            GameAttribute       newGameAttribute  = new GameAttribute(partial.Name, baseGameAttribute.GeometryType, geometryParameters);
            AppearanceAttribute newAppearanceAttr = new AppearanceAttribute();
            bool appearancePropertiesEncountered  = false;

            if (partial.VariableAssignments.ContainsKey("Invented"))
            {
                newGameAttribute.Invented = (string)partial.VariableAssignments["Invented"];
            }
            if (partial.VariableAssignments.ContainsKey("InventedBy"))
            {
                newGameAttribute.InventedBy = (string)partial.VariableAssignments["InventedBy"];
            }
            if (partial.VariableAssignments.ContainsKey("GameDescription1"))
            {
                newGameAttribute.GameDescription1 = (string)partial.VariableAssignments["GameDescription1"];
                if (partial.VariableAssignments.ContainsKey("GameDescription2"))
                {
                    newGameAttribute.GameDescription2 = (string)partial.VariableAssignments["GameDescription2"];
                }
            }
            if (partial.VariableAssignments.ContainsKey("Tags"))
            {
                newGameAttribute.Tags = (string)partial.VariableAssignments["Tags"];
            }
            else
            {
                newGameAttribute.Tags = "";
            }
            if (partial.VariableAssignments.ContainsKey("ColorScheme"))
            {
                appearancePropertiesEncountered = true;
                newAppearanceAttr.ColorScheme   = (string)partial.VariableAssignments["ColorScheme"];
            }
            if (partial.VariableAssignments.ContainsKey("NumberOfColors"))
            {
                appearancePropertiesEncountered        = true;
                newAppearanceAttr.NumberOfSquareColors = Convert.ToInt32(partial.VariableAssignments["NumberOfColors"]);
            }
            if (partial.VariableAssignments.ContainsKey("PieceSet"))
            {
                appearancePropertiesEncountered = true;
                newAppearanceAttr.PieceSet      = (string)partial.VariableAssignments["PieceSet"];
            }
            if (partial.VariableAssignments.ContainsKey("Player1Color"))
            {
                appearancePropertiesEncountered = true;
                newAppearanceAttr.Player1Color  = (string)partial.VariableAssignments["Player1Color"];
            }
            if (partial.VariableAssignments.ContainsKey("Player2Color"))
            {
                appearancePropertiesEncountered = true;
                newAppearanceAttr.Player1Color  = (string)partial.VariableAssignments["Player2Color"];
            }
            GameTypes.Add(partial.Name, newGameType);
            GameAttributes.Add(partial.Name, newGameAttribute);
            if (appearancePropertiesEncountered)
            {
                GameAppearances.Add(partial.Name, newAppearanceAttr);
            }
        }