public GOWrapper(GOType t, GameObject g, int guid, int extra = -1) { go = g; type = t; this.guid = guid; this.extra = extra; }
/*private int xtra = 0; * public void _switch() * { * xtra++; * if (xtra > 3) * xtra = 0; * ChangePhase(WorldState.CENTER, (WorldStateExtra)xtra); * }*/ public int Spawn(GOType type, Vector3 pos, int guid = -1, int extra = 0) { GameObject go; int _guid = -1; switch (type) { case GOType.GO_PLAYER: go = player_pool.Pop(pos, Quaternion.identity); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); BomberController controller = go.GetComponent <BomberController>(); controller.ColorIndex = extra; break; case GOType.GO_BOMB: go = bomb_pool.Pop(pos, Quaternion.identity); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); break; case GOType.GO_PWRUP: go = pwr_up_pool.Pop(pos, Quaternion.identity); PowerUpGOScript sc = go.GetComponent <PowerUpGOScript>(); sc.type = (Config.PowerType)extra; sc.Init(); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); break; } if (_guid > 0 && ((GameMgr.Instance.Type & GameMgrType.SERVER) != 0)) { GameMgr.Instance.s.SendPacketBroadCast(PacketBuilder.BuildInstantiateObjPacket(ObjectMgr.Instance.DumpData(_guid))); } return(_guid); }
private static GameObject CreateGameObject(uint currentObjBaseAddress) { ulong guid = Memory.Read <ulong>(currentObjBaseAddress + (int)ObjectOffsets.Guid); GOType type = (GOType)Memory.Read <short>(currentObjBaseAddress + (uint)ObjectOffsets.Type); GameObject go = null; switch (type) { case GOType.None: break; case GOType.Item: //do this later go = new GameObject(currentObjBaseAddress, guid, type); break; case GOType.Container: //do this later go = new GameObject(currentObjBaseAddress, guid, type); break; case GOType.Unit: string name = GetName(currentObjBaseAddress); if (false == reactionCache.ContainsKey(guid)) { reactionCache.Add(guid, LuaHelper.GetReactionType(guid)); } ReactionType reaction = reactionCache[guid]; go = new Unit(currentObjBaseAddress, guid, type, name, reaction); break; case GOType.Player: //do this later go = new GameObject(currentObjBaseAddress, guid, type); break; case GOType.GameObject: go = new GameObject(currentObjBaseAddress, guid, type); break; case GOType.DynamicObject: //do this later go = new GameObject(currentObjBaseAddress, guid, type); break; case GOType.Corpse: //do this later go = new GameObject(currentObjBaseAddress, guid, type); break; default: break; } return(go); }
public int Register(GameObject o, GOType type, int guid = -1, int extra = -1) { if (guid < 0) { guid = _guid++; } Debug.Log("register go, type : " + type + ", guid :" + guid); m_objects[guid] = new GOWrapper(type, o, guid, extra); o.GetComponent <Guid>().SetGUID(guid); return(guid); }
bool triggerItemsContainsKey(GOType g) { foreach (KeyValuePair <GOType, Transform> e in triggerItems) { if (e.Key == g) { return(true); } } return(false); }
public IList <GameObject> Get(GOType type) { IList <GameObject> objs = new List <GameObject>(); foreach (var obj in m_objects) { if (obj.Value.type == type) { objs.Add(obj.Value.go); } } return(objs); }
public void Despawn(GOType type, int guid) { GameObject go = ObjectMgr.Instance.Get(guid); if (go != null) { ObjectMgr.Instance.UnRegister(guid); Despawn(type, go); } if (((GameMgr.Instance.Type & GameMgrType.SERVER) != 0)) { GameMgr.Instance.s.SendPacketBroadCast(PacketBuilder.BuildDespawn(guid)); } }
/// <summary> /// Returns a list of all registered AteObjects that match given GOType. /// </summary> public List <AteObject> GetAteObjects(GOType theType) { List <AteObject> theObjects = new List <AteObject> (); if (!_registeredAteObjects.ContainsKey(theType)) { return(theObjects); } for (int i = 0; i < _registeredAteObjects[theType].Count; i++) { theObjects.Add(_registeredAteObjects[theType][i]); } return(theObjects); }
private void Despawn(GOType type, GameObject go) { switch (type) { case GOType.GO_PLAYER: player_pool.Free(go); break; case GOType.GO_BOMB: bomb_pool.Free(go); break; case GOType.GO_PWRUP: pwr_up_pool.Free(go); break; } }
/// <summary> /// Returns a list of all registered AteObjects that match given GOType. /// Results are limited to classes matching given class type. /// </summary> public List <T> GetAteObjects <T> (GOType theType) where T : AteComponent { List <T> theObjects = new List <T> (); if (!_registeredAteObjects.ContainsKey(theType)) { return(theObjects); } for (int i = 0; i < _registeredAteObjects[theType].Count; i++) { T curObject = _registeredAteObjects[theType][i] as T; if (curObject != null) { theObjects.Add(curObject); } } return(theObjects); }
/// <summary> /// Draws the inspector. /// </summary> public void DrawInspector() { EditorGUILayout.LabelField(gameObject.name); type = (GOType)EditorGUILayout.EnumPopup("Game Object Type", type); EditorGUILayout.Space(); _showAteAddRemove = EditorGUILayout.Toggle("Show Add/Remove Options", _showAteAddRemove); if (_showAteAddRemove) { DrawComponentRemover(); EditorGUILayout.Space(); DrawComponentAdder(); } EditorGUILayout.Space(); DrawComponentList(); }
public GameObject GOCreateInRandomPos(GOType goType) { int x = random.Next(0, dimension); int y = random.Next(0, dimension); switch (goType) { case GOType.Player: return(new Player(x, y)); case GOType.Enemy: return(new Enemy(x, y, (EnemyType)random.Next(0, 2))); case GOType.Bonus: return(new Bonus(x, y, (BonusType)random.Next(0, 3))); case GOType.Block: return(new Block(x, y)); default: return(new Block(x, y)); } }
public Unit(uint baseAddress, ulong Guid, GOType Type, string Name, ReactionType Reaction) : base(baseAddress, Guid, Type) { this.Name = Name; this.Reaction = Reaction; }
public void triggerItemsAdd(GOType g, Transform t) { triggerItems.Add(new KeyValuePair <GOType, Transform> (g, t)); }
public GameObject(uint BaseAddress, ulong Guid, GOType Type) { this.BaseAddress = BaseAddress; this.Guid = Guid; this.Type = Type; }