public static PowerShard JSONToPowerShard(JSONObject powerShard, Hexagon position) { int coolDown=(int)powerShard.GetField("coolDown").n; List<JSONObject> ids = powerShard.GetField("effectIds").list; List<int> effectIds = new List<int>(); foreach(JSONObject jo in ids) { effectIds.Add((int)jo.n); } PowerShard ps = new PowerShard(position, coolDown, effectIds); ps.GameObject = new GameObject(); CapsuleCollider collider = ps.GameObject.AddComponent<CapsuleCollider>(); collider.height = 5; collider.radius = 0.5f; ps.GameObject.name = powerShard.GetField("gameObject").str; return ps; }
public void RemovePowerShard(PowerShard shard) { PowerShards.Remove(shard); }
public void AddPowerShard(PowerShard shard) { PowerShards.Add(shard); }
public void BuildShard() { Hexagon hex = PlayBoardManager.GetInstance().Board.GetHexagone(x, y); if (hex != null && !(hex._posX < 0)) { if (hex.GameObject != null && hex._entity == null) { GameObject go = Instantiate<GameObject>(shard); go.transform.position = new Vector3(0.866f * x - 0.433f * y, z, 0.75f * y); go.transform.parent = hex.GameObject.transform; go.name = shard.name; go.layer = LayerMask.NameToLayer("Obstacle"); PowerShard powerShard = new PowerShard(hex, coolDownShard, shardsEffects); powerShard.GameObject = go; hex._entity = powerShard; PlayBoardManager.GetInstance().Board.AddPowerShard(powerShard); } } }