예제 #1
0
        public static object GetObjectsStartingFromIndex(object msg)
        {
            GetObjectsFromIndexMessage data = (GetObjectsFromIndexMessage)msg;

            switch (data.type)
            {
            case "node":
                return(NetLogic.PrepareNodesStartingFromIndex((ushort)data.index));

            case "segment":
                return(NetLogic.PrepareSegmentsStartingFromIndex((ushort)data.index));

            case "building":
                return(ManagersLogic.PrepareBuildingsStartingFromIndex((ushort)data.index));

            case "prop":
                return(ManagersLogic.PreparePropsStartingFromIndex((ushort)data.index));

            case "tree":
                return(ManagersLogic.PrepareTreesStartingFromIndex((uint)data.index));

            default:
                throw new Exception($"Unknown type '{data.type}'");
            }
        }
예제 #2
0
 public object ToMessage()
 {
     if (ObjectType == Type.Point)
     {
         return(_point.position.FromUnity());
     }
     else if (ObjectType == Type.Node)
     {
         return(NetLogic.PrepareNode((ushort)Id));
     }
     else if (ObjectType == Type.Segment)
     {
         return(NetLogic.PrepareSegment((ushort)Id));
     }
     else if (ObjectType == Type.Building)
     {
         return(ManagersLogic.PrepareBuilding((ushort)Id));
     }
     else if (ObjectType == Type.Prop)
     {
         return(ManagersLogic.PrepareProp((ushort)Id));
     }
     else
     {
         return(ManagersLogic.PrepareTree(Id));
     }
 }
예제 #3
0
        private static object GetObjectFromIdInternal(uint id, string idString, string type)
        {
            object ret;

            switch (type)
            {
            case "node":
                ret = NetLogic.PrepareNode((ushort)(id));
                break;

            case "segment":
                ret = NetLogic.PrepareSegment((ushort)(id));
                break;

            case "building":
                ret = ManagersLogic.PrepareBuilding((ushort)(id));
                break;

            case "prop":
                ret = ManagersLogic.PrepareProp((ushort)(id));
                break;

            case "tree":
                ret = ManagersLogic.PrepareTree((uint)(id));
                break;

            case "net prefab":
                ret = NetLogic.PrepareNetInfo(idString);
                break;

            default:
                throw new Exception($"Unknown type '{type}'");
            }
            return(ret);
        }
예제 #4
0
        public static object CreateProp(object msg)
        {
            var      data = (CreatePropMessage)msg;
            PropInfo info = PrefabCollection <PropInfo> .FindLoaded(data.Type);

            Util.Assert(info, "Prefab '" + data.Type + "' not found");
            return(ManagersLogic.PrepareProp(ManagersUtil.CreateProp(data.Position.ToUnityTerrain(), (float)data.Angle, info, true)));
        }
예제 #5
0
        public static object CreateTree(object msg)
        {
            var data = (CreateTreeMessage)msg;

            TreeInfo info = PrefabCollection <TreeInfo> .FindLoaded(data.prefab_name);

            Util.Assert(info, "Prefab '" + data.prefab_name + "' not found");
            uint id = ManagersUtil.CreateTree(data.Position.ToUnityTerrain(), info, true);

            return(ManagersLogic.PrepareTree(id));
        }
예제 #6
0
        public static InstanceData Move(MoveMessage msg)
        {
            switch (msg.type)
            {
            case "node":
                MoveableNode mnode = new MoveableNode(new InstanceID()
                {
                    NetNode = (ushort)msg.id
                });
                mnode.MoveCall(msg.position != null ? msg.position.ToUnity() : mnode.position);
                return(NetLogic.PrepareNode((ushort)msg.id));

            case "segment":
                MoveableSegment seg = new MoveableSegment(new InstanceID()
                {
                    NetSegment = (ushort)msg.id
                });
                seg.MoveCall(msg.position != null ? msg.position.ToUnity() : seg.position);
                return(NetLogic.PrepareSegment((ushort)msg.id));

            case "building":
                MoveableBuilding b = new MoveableBuilding(new InstanceID()
                {
                    Building = (ushort)msg.id
                });
                b.MoveCall(msg.position != null ? msg.position.ToUnity() : b.position, msg.is_angle_defined ? msg.angle : b.angle);
                return(ManagersLogic.PrepareBuilding((ushort)msg.id));

            case "prop":
                MoveableProp p = new MoveableProp(new InstanceID()
                {
                    Prop = (ushort)msg.id
                });
                p.MoveCall(msg.position != null ? msg.position.ToUnity() : p.position, msg.is_angle_defined ? msg.angle : p.angle);
                return(ManagersLogic.PrepareProp((ushort)msg.id));

            case "tree":
                MoveableTree t = new MoveableTree(new InstanceID()
                {
                    Tree = msg.id
                });
                t.MoveCall(msg.position != null ? msg.position.ToUnity() : t.position);
                return(ManagersLogic.PrepareTree(msg.id));

            default:
                throw new Exception($"Cannot move {msg.type}");
            }
        }
예제 #7
0
        public static object GetNaturalResourceCells(object msg)
        {
            var cells  = Singleton <NaturalResourceManager> .instance.m_naturalResources;
            var mapped = new NaturalResourceCellBase[cells.Length];

            for (int i = 0; i < cells.Length; i++)
            {
                mapped[i] = ManagersLogic.ConvertResourceCell(i);

                /*mapped[i].ore = cells[i].m_ore;
                 * mapped[i].oil = cells[i].m_oil;
                 * mapped[i].forest = cells[i].m_forest;
                 * mapped[i].fertility = cells[i].m_fertility;
                 * mapped[i].pollution = cells[i].m_pollution;
                 * mapped[i].water = cells[i].m_water;*/
            }
            return(mapped);
        }
예제 #8
0
 public static object SetNaturalResource(object msg)
 {
     ManagersLogic.SetNaturalResource((SetNaturalResourceMessage)msg);
     return(null);
 }
예제 #9
0
 public static object GetNaturalResourceCellSingle(object msg)
 {
     return(ManagersLogic.ConvertResourceCell((int)msg));
 }
예제 #10
0
 public static object MoveObject(object msg)
 {
     return(ManagersLogic.Move((MoveMessage)msg));
 }
예제 #11
0
 public static object GetBuildingFromId(object msg)
 {
     return(ManagersLogic.PrepareBuilding((ushort)((uint)msg)));
 }
예제 #12
0
 public static object GetTreeFromId(object msg)
 {
     return(ManagersLogic.PrepareTree((uint)((uint)msg)));
 }
예제 #13
0
 public static object GetPropFromId(object msg)
 {
     return(ManagersLogic.PrepareProp((ushort)((uint)msg)));
 }