Exemple #1
0
        public EntityBodyPart(Transform parent, SerializedBodyPart bp, bool hasCollider)
        {
            serializedBodyPart = bp;

            go = new GameObject();
            go.transform.parent     = parent;
            go.transform.localScale = bp.scale * Vector3.one;

            SpriteRenderer sr = go.AddComponent <SpriteRenderer>();

//            sr.sortingLayerName = "Foreground";
//          sr.sortingLayerID = 9;
            sr.color  = Color.white;
            sr.sprite = Sprites.GetTexture(bp.texture);
            if (hasCollider)
            {
                go.AddComponent <BoxCollider2D>();
            }
            //          go.AddComponent<Rigidbody2D>();
            Physics2D.gravity = Vector2.zero;
            foreach (SerializedBodyPart sbp in bp.bodyParts)
            {
                bodyparts.Add(new EntityBodyPart(go.transform, sbp, false));
            }
        }
        public SerializedBodyPart Copy()
        {
            SerializedBodyPart bp = new SerializedBodyPart();

            bp.texture            = texture;
            bp.moveSpeed          = moveSpeed;
            bp.rotateSpeed        = rotateSpeed;
            bp.minSpeed           = minSpeed;
            bp.translate_x        = translate_x;
            bp.translate_y        = translate_y;
            bp.translate_z        = translate_z;
            bp.scale              = scale;
            bp.rotateTexture      = rotateTexture;
            bp.directionFromSpeed = directionFromSpeed;

            if (weapon != null)
            {
                bp.weapon = weapon.Copy();
            }

            foreach (SerializedBodyPart nbp in bodyParts)
            {
                bp.bodyParts.Add(nbp.Copy());
            }

            return(bp);
        }
Exemple #3
0
 public EntityBodyPart(Transform parent, SerializedBodyPart bp)
 {
     serializedBodyPart = bp;
     go = parent.GetChild(0).gameObject;
     foreach (SerializedBodyPart sbp in bp.bodyParts)
     {
         bodyparts.Add(new EntityBodyPart(go.transform, sbp));
     }
 }
        public static void Generate()
        {
            SerializedEntities test = new SerializedEntities();
            SerializedEntity   sen  = new SerializedEntity();
            SerializedBodyPart bp   = new SerializedBodyPart();

            bp.bodyParts.Add(new SerializedBodyPart());
            sen.body = bp;
            test.entities.Add(sen);
            Serialize(test, Constants.EntitiesXML);
        }