Exemplo n.º 1
0
 public FarmObject(XElement element, GameObjectTypes type)
 {
     Type    = type;
     Element = element;
     SetValues();
     SetTileXYRange();
 }
Exemplo n.º 2
0
        public GameObject Create(GameObjectTypes type, Vector3 position)
        {
            var o = Create(type);

            o.transform.position = position;
            return(o);
        }
Exemplo n.º 3
0
        public void TriggerAnimation(GameObjectTypes type, Vector2 location, string textureassetname, int depth)
        {
            int key = factory.Create((int)type, location, textureassetname, Vector2.Zero, 0f, 0f, 0f, depth);

            float animationTime = 1000 * factory.Objects[key].sprite.FrameTime * factory.Objects[key].sprite.FrameCount;

            RemoveAfter(key, animationTime);
        }
Exemplo n.º 4
0
 public IDataManager getManager(GameObjectTypes type)
 {
     if (!MANAGERS.ContainsKey(type))
     {
         Debug.LogError("没有此种类型的data配置!:" + type);
         return(null);
     }
     return(MANAGERS[type]);
 }
Exemplo n.º 5
0
        public void TriggerAnimation(GameObjectTypes type, Vector2 location, string textureassetname, int depth)
        {
            int key = factory.Create((int)type, location, textureassetname, Vector2.Zero, 0f, 0f, 0f, depth);

            float animationTime = 1000 * factory.Objects[key].sprite.FrameTime * factory.Objects[key].sprite.FrameCount;

            RemoveAfter(key, animationTime);
            
        }
Exemplo n.º 6
0
 public FarmObject(GameObjectTypes type, int x, int y, int w, int h)
 {
     Type    = type;
     Element = null;
     TileX   = x;
     TileY   = y;
     Width   = w;
     Height  = h;
     SetTileXYRange();
 }
Exemplo n.º 7
0
 public static GameObject GenerateObject(this GameObjectTypes type, GameModel game, int x, int y)
 {
     if (type == GameObjectTypes.CollectableItem)
     {
         var random   = Utils.GetRandomInt();
         var itemType = random > 50 ? random > 80 ? ItemTypes.Shield : ItemTypes.SharpeningStone : ItemTypes.Boots;
         return(CollectableItemsFactory.Items[itemType](game, new Point(x, y)));
     }
     return((GameObject)GameObjectTypesToType[type].GetConstructor(new[] { typeof(GameModel), typeof(int), typeof(int) }).Invoke(new object[] { game, x, y }));
 }
Exemplo n.º 8
0
        public void TriggerFadeUp(GameObjectTypes type, Vector2 location, string textureassetname)
        {
            int key = factory.Create((int)type, location, textureassetname, new Vector2(0, -100), 0f, 0f, 0f, 32);

            factory.Objects[key].sprite.FrameTime = 0.1f;
            factory.Objects[key].sprite.Fade      = true;

            items.Add(new TimedItem(
                          delegate()
            {
                GameObjectFactory.Instance.Remove(key);
            },
                          1000));
        }
Exemplo n.º 9
0
        public void TriggerFadeUp(GameObjectTypes type, Vector2 location, string textureassetname)
        {
            int key = factory.Create((int)type, location, textureassetname, new Vector2(0, -100), 0f, 0f, 0f, 32);

            factory.Objects[key].sprite.FrameTime = 0.1f;
            factory.Objects[key].sprite.Fade = true;

            items.Add(new TimedItem(
            delegate()
            {
                GameObjectFactory.Instance.Remove(key);
            },
            1000));

        }
Exemplo n.º 10
0
        public Game1()
            : base()
        {
            GameObjectTypes.Initialize();

            this.inputManager = new InputManager();

            this.graphics = new GraphicsDeviceManager(this);
            this.graphics.HardwareModeSwitch        = false;
            this.graphics.IsFullScreen              = false;
            this.graphics.PreferredBackBufferWidth  = 1920;
            this.graphics.PreferredBackBufferHeight = 1080;
            this.Window.IsBorderless      = false;
            this.Window.AllowUserResizing = false;
            this.InactiveSleepTime        = new TimeSpan(0);
            this.IsFixedTimeStep          = false;
            this.IsMouseVisible           = true;
            this.graphics.ApplyChanges();
        }
Exemplo n.º 11
0
        public GameObject Create(GameObjectTypes type)
        {
            GameObject o = null;

            switch (type)
            {
            case GameObjectTypes.PrimitiveCapsule:
                o = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                break;

            case GameObjectTypes.PrimitiveCube:
                o = GameObject.CreatePrimitive(PrimitiveType.Cube);
                break;

            case GameObjectTypes.PrimitiveCylinder:
                o = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                break;

            case GameObjectTypes.PrimitiveSphere:
                o = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                break;

            case GameObjectTypes.PrimitivePlane:
                o = GameObject.CreatePrimitive(PrimitiveType.Plane);
                break;

            case GameObjectTypes.PrimitiveQuad:
                o = GameObject.CreatePrimitive(PrimitiveType.Quad);
                break;
            }

            if (o != null)
            {
                WorldDataChunkContent.GameObjects.Add(o);
            }
            return(o);
        }
Exemplo n.º 12
0
 public void setAttTargetType(GameObjectTypes value)
 {
     _attTargetType = value;
 }
Exemplo n.º 13
0
    public static Sprite getSpriteBuyGameObjectType(GameObjectTypes objectType)
    {
        Sprite anotherSprite = spriteSettingsForGameObjectTypes[objectType];

        return(anotherSprite);
    }
Exemplo n.º 14
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            uint            entry     = 0;
            GameObjectTypes type      = 0;
            uint            displayId = 0;
            uint            lootId    = 0;

            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.extractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            if (param1.Equals("guid"))
            {
                string cValue = handler.extractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out ulong guidLow))
                {
                    return(false);
                }

                GameObjectData data = Global.ObjectMgr.GetGOData(guidLow);
                if (data == null)
                {
                    return(false);
                }
                entry = data.id;
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                return(false);
            }

            type      = gameObjectInfo.type;
            displayId = gameObjectInfo.displayId;
            string name = gameObjectInfo.name;

            lootId = gameObjectInfo.GetLootId();

            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            if (addon != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags);
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }
Exemplo n.º 15
0
 public bool IsGameObjectType(GameObjectTypes type)
 {
     return(Convert.ToBoolean(type & GetGoInfo().type));
 }
Exemplo n.º 16
0
 void SetGoType(GameObjectTypes type)
 {
     SetValue <byte>(GameObjectFields.Bytes, (byte)type, 1);
 }
Exemplo n.º 17
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.ExtractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            GameObject     thisGO = null;
            GameObjectData data   = null;

            uint  entry;
            ulong spawnId = 0;

            if (param1.Equals("guid"))
            {
                string cValue = handler.ExtractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out spawnId))
                {
                    return(false);
                }

                data = Global.ObjectMgr.GetGameObjectData(spawnId);
                if (data == null)
                {
                    handler.SendSysMessage(CypherStrings.CommandObjnotfound, spawnId);
                    return(false);
                }

                entry  = data.Id;
                thisGO = handler.GetObjectFromPlayerMapByDbGuid(spawnId);
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                handler.SendSysMessage(CypherStrings.GameobjectNotExist, entry);
                return(false);
            }

            GameObjectTypes type      = gameObjectInfo.type;
            uint            displayId = gameObjectInfo.displayId;
            string          name      = gameObjectInfo.name;
            uint            lootId    = gameObjectInfo.GetLootId();

            // If we have a real object, send some info about it
            if (thisGO != null)
            {
                handler.SendSysMessage(CypherStrings.SpawninfoGuidinfo, thisGO.GetGUID().ToString());
                handler.SendSysMessage(CypherStrings.SpawninfoCompatibilityMode, thisGO.GetRespawnCompatibilityMode());

                if (thisGO.GetGameObjectData() != null && thisGO.GetGameObjectData().spawnGroupData.groupId != 0)
                {
                    SpawnGroupTemplateData groupData = thisGO.ToGameObject().GetGameObjectData().spawnGroupData;
                    handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, thisGO.GetMap().IsSpawnGroupActive(groupData.groupId));
                }

                GameObjectOverride goOverride = Global.ObjectMgr.GetGameObjectOverride(spawnId);
                if (goOverride == null)
                {
                    goOverride = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);
                }
                if (goOverride != null)
                {
                    handler.SendSysMessage(CypherStrings.GoinfoAddon, goOverride.Faction, goOverride.Flags);
                }
            }

            if (data != null)
            {
                data.rotation.toEulerAnglesZYX(out float yaw, out float pitch, out float roll);
                handler.SendSysMessage(CypherStrings.SpawninfoSpawnidLocation, data.SpawnId, data.SpawnPoint.GetPositionX(), data.SpawnPoint.GetPositionY(), data.SpawnPoint.GetPositionZ());
                handler.SendSysMessage(CypherStrings.SpawninfoRotation, yaw, pitch, roll);
            }

            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            handler.SendSysMessage(CypherStrings.ObjectInfoAIInfo, gameObjectInfo.AIName, Global.ObjectMgr.GetScriptName(gameObjectInfo.ScriptId));
            var ai = thisGO != null?thisGO.GetAI() : null;

            if (ai != null)
            {
                handler.SendSysMessage(CypherStrings.ObjectInfoAIType, nameof(ai));
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }
Exemplo n.º 18
0
 public void TriggerAnimation(GameObjectTypes type, Vector2 location, string textureassetname)
 {
     TriggerAnimation(type, location, textureassetname, 64);
 }
Exemplo n.º 19
0
 public void TriggerAnimation(GameObjectTypes type, Vector2 location, string textureassetname)
 {
     TriggerAnimation(type, location, textureassetname, 64);
 }
Exemplo n.º 20
0
 internal GameObject Create(GameObjectTypes type, int x, int z)
 {
     return(Create(type, S.ChunkCenterWorldAtDefaultElevation(x, z)));
 }
Exemplo n.º 21
0
 public static string UToString(this GameObjectTypes type) => ObjectTypesRepr[type];
Exemplo n.º 22
0
        static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler)
        {
            if (args.Empty())
            {
                return(false);
            }

            string param1 = handler.ExtractKeyFromLink(args, "Hgameobject_entry");

            if (param1.IsEmpty())
            {
                return(false);
            }

            uint entry;

            if (param1.Equals("guid"))
            {
                string cValue = handler.ExtractKeyFromLink(args, "Hgameobject");
                if (cValue.IsEmpty())
                {
                    return(false);
                }

                if (!ulong.TryParse(cValue, out ulong guidLow))
                {
                    return(false);
                }

                GameObjectData data = Global.ObjectMgr.GetGameObjectData(guidLow);
                if (data == null)
                {
                    return(false);
                }
                entry = data.Id;
            }
            else
            {
                if (!uint.TryParse(param1, out entry))
                {
                    return(false);
                }
            }

            GameObjectTemplate gameObjectInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);

            if (gameObjectInfo == null)
            {
                return(false);
            }

            GameObject thisGO = null;

            if (handler.GetSession().GetPlayer())
            {
                thisGO = handler.GetSession().GetPlayer().FindNearestGameObject(entry, 30);
            }
            else if (handler.GetSelectedObject() != null && handler.GetSelectedObject().IsTypeId(TypeId.GameObject))
            {
                thisGO = handler.GetSelectedObject().ToGameObject();
            }

            GameObjectTypes type      = gameObjectInfo.type;
            uint            displayId = gameObjectInfo.displayId;
            string          name      = gameObjectInfo.name;
            uint            lootId    = gameObjectInfo.GetLootId();

            // If we have a real object, send some info about it
            if (thisGO != null)
            {
                handler.SendSysMessage(CypherStrings.SpawninfoGuidinfo, thisGO.GetGUID().ToString());
                handler.SendSysMessage(CypherStrings.SpawninfoSpawnidLocation, thisGO.GetSpawnId(), thisGO.GetPositionX(), thisGO.GetPositionY(), thisGO.GetPositionZ());
                Player player = handler.GetSession().GetPlayer();
                if (player != null)
                {
                    Position playerPos = player.GetPosition();
                    float    dist      = thisGO.GetExactDist(playerPos);
                    handler.SendSysMessage(CypherStrings.SpawninfoDistancefromplayer, dist);
                }
            }
            handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
            handler.SendSysMessage(CypherStrings.GoinfoType, type);
            handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
            handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
            WorldObject obj = handler.GetSelectedObject();

            if (obj != null)
            {
                if (obj.IsGameObject() && obj.ToGameObject().GetGameObjectData() != null && obj.ToGameObject().GetGameObjectData().spawnGroupData.groupId != 0)
                {
                    SpawnGroupTemplateData groupData = obj.ToGameObject().GetGameObjectData().spawnGroupData;
                    handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, obj.GetMap().IsSpawnGroupActive(groupData.groupId));
                }
                if (obj.IsGameObject())
                {
                    handler.SendSysMessage(CypherStrings.SpawninfoCompatibilityMode, obj.ToGameObject().GetRespawnCompatibilityMode());
                }
            }
            handler.SendSysMessage(CypherStrings.GoinfoName, name);
            handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);

            GameObjectTemplateAddon addon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);

            if (addon != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoAddon, addon.faction, addon.flags);
            }

            GameObjectDisplayInfoRecord modelInfo = CliDB.GameObjectDisplayInfoStorage.LookupByKey(displayId);

            if (modelInfo != null)
            {
                handler.SendSysMessage(CypherStrings.GoinfoModel, modelInfo.GeoBoxMax.X, modelInfo.GeoBoxMax.Y, modelInfo.GeoBoxMax.Z, modelInfo.GeoBoxMin.X, modelInfo.GeoBoxMin.Y, modelInfo.GeoBoxMin.Z);
            }

            return(true);
        }