Exemple #1
0
    private void SpawnShipPart(ref Dictionary <int, Tool.ShipPart> shipParts)
    {
        foreach (KeyValuePair <int, Tool.ShipPart> part in shipParts)
        {
            EntShipPart partEntity = null;
            if (!_shipPartsEntity.ContainsKey(part.Key))
            {
                //position of part
                GameObject go = null;
                Spawn(ref go, part.Value);
                // set name of part
                go.name = part.Value.Param.Type.ToString();

                // add to dictionnary
                partEntity = go.GetComponent <EntShipPart>();
                // init list of position in entity ship part
                partEntity.Init(part.Value);
                partEntity.PlayerOwner = this;

                // update min and max
                X.x = Mathf.Min(partEntity.X.x, X.x);
                X.y = Mathf.Max(partEntity.X.y, X.y);

                Y.x = Mathf.Min(partEntity.Y.x, Y.x);
                Y.y = Mathf.Max(partEntity.Y.y, Y.y);

                Z.x = Mathf.Min(partEntity.Z.x, Z.x);
                Z.y = Mathf.Max(partEntity.Z.y, Z.y);

                _shipPartsEntity.Add(part.Key, partEntity);
            }
            else // for editor
            {
                partEntity = _shipPartsEntity[part.Key];
                // init list of position in entity ship part
                partEntity.Init(part.Value);
            }
        }
    }
Exemple #2
0
        private void CreatePart(int hashId)
        {
            // spawn entity ship part
            GameObject obj  = null;
            ShipPart   part = new ShipPart(ParamCube);

            Spawn(ref obj, part);
            EntShipPart entity = obj.GetComponent <EntShipPart>();

            entity.Init(part);

            // force start on entity
            entity.Start();

            ShipPartEntities.Add(hashId, entity);
        }
Exemple #3
0
        public void CreateParts(ref Dictionary <int, Tool.ShipPart> shipParts)
        {
            foreach (KeyValuePair <int, Tool.ShipPart> part in shipParts)
            {
                GameObject partObj = null;
                Spawn(ref partObj, part.Value);
                // set name of part
                partObj.name = part.Value.Param.Type.ToString();

                // init list of position in entity ship part
                EntShipPart entShipPart = partObj.GetComponent <EntShipPart>();
                entShipPart.Init(part.Value);

                // force start on entity
                entShipPart.Start();

                ShipPartEntities.Add(part.Key, entShipPart);
            }
        }