Пример #1
0
    static StringBuilder GetEndPositionJson(Level.GamePositions pEndPosition, ref StringBuilder pResources)
    {
        StringBuilder aEndPositionGobj = new StringBuilder("{");

        aEndPositionGobj.Append("\"name\" : \"End Position\",\n");
        aEndPositionGobj.Append("\"enabled\" : false,\n");
        aEndPositionGobj.Append("\"Components\" : [\n");
        GTransform aTransform = new GTransform();

        aTransform.Position = new position(pEndPosition.mWorldPosition.x * 64.00001f, pEndPosition.mWorldPosition.y * 64.00001f);
        aEndPositionGobj.Append(aTransform.ToString());
        aEndPositionGobj.Append(",\n");
        string  aSpGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(pEndPosition.mDisplaySprite));
        GSprite aSprite = new GSprite(pEndPosition.mDisplaySprite.rect, aSpGUID,
                                      pEndPosition.mDisplaySprite.texture.height, (int)Level.LayerTypes.Players);

        SaveAssetData(GetAssetFromGUID(aSpGUID, AssetMetaData.AssetType.TextureAsset), ref pResources);
        aEndPositionGobj.Append(aSprite.ToString() + ",\n");
        GPolygonCollider aPolygonCollider = new GPolygonCollider(true);

        aEndPositionGobj.Append(aPolygonCollider.ToString() + ",\n");
        Teleporter aTeleporter = new Teleporter();

        aEndPositionGobj.Append(aTeleporter.ToString());
        aEndPositionGobj.Append("]\n");
        aEndPositionGobj.Append("}");
        return(aEndPositionGobj);
    }
Пример #2
0
        // End All SpriteFont

        // Ham nay dung tam thoi`. De opt game thi phai phan chia theo tung State
        public void Init(ContentManager Content)
        {
            // Init Sprite
            SpriteSquare = new GSprite(Content, @"Resource\\RedSquare", new Point(40, 40), 9, 9, Color.White);

            // Init SpriteFont
            ArialFont = Content.Load <SpriteFont>(@"Font\\ArialFont");
        }
Пример #3
0
 public GObject(GObject Obj)
 {
     m_ID         = Obj.m_ID;
     m_Position   = Obj.m_Position;
     m_Status     = Obj.m_Status;
     m_Sprite     = new GSprite(Obj.SPRITE);
     m_TotalFrame = Obj.m_TotalFrame;
     m_Origin     = new Vector2(Obj.m_Origin.X, Obj.Origin.Y);
 }
Пример #4
0
 public GObject(eGMyObject eObj, eGStatus estt, Vector2 position, GSprite sprite)
 {
     this.m_ID       = eObj;
     this.STATUS     = estt;
     this.POSITION   = position;
     this.SPRITE     = new GSprite(sprite);
     this.SIZE       = new Point(SPRITE.Size.X, SPRITE.Size.Y);
     this.TOTALFRAME = sprite.TotalFrame;
     this.Time       = new GTimer();
     m_Origin        = new Vector2(this.POSITION.X + SIZE.X / 2, this.POSITION.Y + SIZE.Y / 2);
 }
Пример #5
0
    static void SaveEnemyPrefab(AssetMetaData pEnemy, ref StringBuilder pResources)
    {
        if (pEnemy == null)
        {
            return;
        }
        Enemy  aEnemy         = AssetDatabase.LoadAssetAtPath <Enemy>(AssetDatabase.GUIDToAssetPath(pEnemy.mGUID));
        string aEnemyFilePath = "/Assets/Resources/Prefabs/" + aEnemy.mName + ".json";

        pEnemy.mAssetFilePath = ".." + aEnemyFilePath;
        if (aEnemy.mEnemyType == Enemy.Type.ProjectileThrower)
        {
            SaveProjectile(GetAssetFromGUID(aEnemy.mProjectileGUID, AssetMetaData.AssetType.PrefabAsset), ref pResources);
        }
        SaveAssetData(GetAssetFromGUID(aEnemy.mEnemyAnimations[0].mTextureAssetGUID, AssetMetaData.AssetType.TextureAsset), ref pResources);
        if (!IsAssetInResources(Application.dataPath + aEnemyFilePath))
        {
            GEnemy aEnemyComp = new GEnemy();
            aEnemyComp.mType      = aEnemy.mEnemyType;
            aEnemyComp.mSpeed     = aEnemy.mSpeed;
            aEnemyComp.mStopRange = aEnemy.mStopRange;
            if (aEnemyComp.mType == Enemy.Type.ProjectileThrower)
            {
                aEnemyComp.mProjectileGUID = aEnemy.mProjectileGUID;
            }
            GSprite aSprite = new GSprite(aEnemy.mDisplaySprite.rect, aEnemy.mEnemyAnimations[0].mTextureAssetGUID,
                                          aEnemy.mDisplaySprite.texture.height, (int)aEnemy.mRenderLayer);
            GRigidbody      aRigidBody   = new GRigidbody();
            GCircleCollider aCollider    = new GCircleCollider(32.00001f, false);
            StringBuilder   aEnemyObject = new StringBuilder("{\n");
            aEnemyObject.Append("\"name\" : \"" + aEnemy.mName + "\",\n");
            aEnemyObject.Append("\"Components\" : [\n");
            aEnemyObject.Append(aSprite.ToString() + ",\n");
            aEnemyObject.Append(aEnemyComp.ToString() + ",\n");
            aEnemyObject.Append(aCollider.ToString() + ",\n");
            aEnemyObject.Append(aRigidBody.ToString() + ",\n");
            aEnemyObject.Append("{\n\"class\" : \"Animator\",\n\"Name\" : \"" + aEnemy.mName + "\"\n},\n");
            foreach (AnimationData aData in aEnemy.mEnemyAnimations)
            {
                GAnimation aAnimation = new GAnimation(aData);
                aEnemyObject.Append(aAnimation.ToString() + ",\n");
            }
            aEnemyObject.Remove(aEnemyObject.Length - 2, 2);
            aEnemyObject.Append("]\n");
            aEnemyObject.Append("}\n");
            SaveToFile(aEnemyObject.ToString(), Application.dataPath + aEnemyFilePath);
            SaveToFile(pEnemy.ToString(), Application.dataPath + aEnemyFilePath + ".json");
        }
        if (!IsPathInResources(pResources, pEnemy.mAssetFilePath + ".json"))
        {
            pResources.Append("\"" + pEnemy.mAssetFilePath + ".json\",");
        }
    }
Пример #6
0
    public Sprite Spr(string spr)
    {
        GSprite s = Array.Find(sprites, item => item.name == spr);

        if (s == null)
        {
            Debug.LogWarning("Sprite: " + name + " not found!");
            return(null);
        }
        Sprite gs = s.spr;

        return(gs);
    }
Пример #7
0
    public GAnimation(AnimationData pData)
    {
        Name             = pData.mAnimationName;
        textureAssetGUID = pData.mTextureAssetGUID;
        Speed            = pData.mAnimSpeed;
        Frames           = new dimensions[pData.mSprites.Count];
        int aI = 0;

        foreach (Sprite aSprite in pData.mSprites)
        {
            GSprite aSp = new GSprite(aSprite.rect, textureAssetGUID, aSprite.texture.height, 0);
            Frames[aI] = aSp.Dimensions;
        }
    }
Пример #8
0
    static StringBuilder GetSpawnFactoryJson(SpawnFactory pFactory, ref StringBuilder pResources)
    {
        StringBuilder aFactoryComponents = new StringBuilder();
        GSprite       aSprite            = new GSprite(pFactory.mDisplaySprite.rect, pFactory.mTextureGUID,
                                                       pFactory.mDisplaySprite.texture.height, (int)pFactory.mRenderLayer);

        SaveAssetData(GetAssetFromGUID(pFactory.mTextureGUID, AssetMetaData.AssetType.TextureAsset), ref pResources);
        aFactoryComponents.Append(aSprite.ToString() + ",\n");
        GPolygonCollider aCollider = new GPolygonCollider(pFactory.mIsTrigger);

        aFactoryComponents.Append(aCollider.ToString() + ",\n");
        SFactory aFactory = new SFactory(pFactory.mEnemyGUID, pFactory.mPoolCount, pFactory.mSpawnTime);

        SaveEnemyPrefab(GetAssetFromGUID(pFactory.mEnemyGUID, AssetMetaData.AssetType.PrefabAsset), ref pResources);
        aFactoryComponents.Append(aFactory.ToString());
        return(aFactoryComponents);
    }
Пример #9
0
    static string[] SaveItemPrefabs()
    {
        StringBuilder aItemsSB   = new StringBuilder("\"resources\" : [\n");
        StringBuilder aItemGUIDs = new StringBuilder("\"mItemGUIDs\" : [\n");

        foreach (AssetMetaData aAsset in mCurrentAssets[AssetMetaData.AssetType.PrefabAsset])
        {
            string aAssetPath = AssetDatabase.GUIDToAssetPath(aAsset.mGUID);
            if (AssetDatabase.GetMainAssetTypeAtPath(aAssetPath) != typeof(Item))
            {
                continue;
            }
            StringBuilder aItemJSON     = new StringBuilder("{\n");
            Item          aItem         = AssetDatabase.LoadAssetAtPath <Item>(aAssetPath);
            string        aItemFilePath = "/Assets/Resources/Prefabs/" + aItem.mName + ".json";
            aAsset.mAssetFilePath = ".." + aItemFilePath;
            if (!IsAssetInResources(Application.dataPath + aItemFilePath))
            {
                aItemJSON.Append("\"name\" : \"" + aItem.mName + "\",\n");
                Pickable aPickable = new Pickable();
                aPickable.mType = aItem.mItemType;
                GPolygonCollider aCollider = new GPolygonCollider(true);
                GSprite          aSprite   = new GSprite(aItem.mDisplaySprite.rect, aItem.mTextureGUID,
                                                         aItem.mDisplaySprite.texture.height, (int)aItem.mRenderLayer);
                SaveAssetData(GetAssetFromGUID(aItem.mTextureGUID, AssetMetaData.AssetType.TextureAsset), ref aItemsSB);
                aItemJSON.Append("\"Components\" : [\n");
                aItemJSON.Append(aSprite.ToString() + ",\n");
                aItemJSON.Append(aPickable.ToString() + ",\n");
                aItemJSON.Append(aCollider.ToString() + "\n");
                aItemJSON.Append("]\n");
                aItemJSON.Append("}\n");
                SaveToFile(aItemJSON.ToString(), Application.dataPath + aItemFilePath);
                SaveToFile(aAsset.ToString(), Application.dataPath + aItemFilePath + ".json");
            }
            if (!IsPathInResources(aItemsSB, aAsset.mAssetFilePath + ".json"))
            {
                aItemsSB.Append("\"" + aAsset.mAssetFilePath + ".json\",");
                aItemGUIDs.Append("\"" + aAsset.mGUID + "\",");
            }
        }
        aItemsSB.Remove(aItemsSB.Length - 1, 1);
        aItemsSB.Append("]\n");
        aItemGUIDs.Remove(aItemGUIDs.Length - 1, 1);
        aItemGUIDs.Append("]\n");
        return(new[] { aItemsSB.ToString(), aItemGUIDs.ToString() });
    }
Пример #10
0
    static int set_isLoadFromAssetBundles(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GSprite obj  = (GSprite)o;
            bool    arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.isLoadFromAssetBundles = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index isLoadFromAssetBundles on a nil value" : e.Message));
        }
    }
Пример #11
0
    static int get_isLoadFromAssetBundles(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            GSprite obj = (GSprite)o;
            bool    ret = obj.isLoadFromAssetBundles;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index isLoadFromAssetBundles on a nil value" : e.Message));
        }
    }
Пример #12
0
    static void SaveProjectile(AssetMetaData pProjectile, ref StringBuilder pResources)
    {
        if (pProjectile == null)
        {
            return;
        }
        Projectile aProjectile         = AssetDatabase.LoadAssetAtPath <Projectile>(AssetDatabase.GUIDToAssetPath(pProjectile.mGUID));
        string     aProjectileFilePath = "/Assets/Resources/Prefabs/" + aProjectile.mName + ".json";

        pProjectile.mAssetFilePath = ".." + aProjectileFilePath;
        SaveAssetData(GetAssetFromGUID(aProjectile.mProjectileAnimation[0].mTextureAssetGUID, AssetMetaData.AssetType.TextureAsset), ref pResources);
        if (!IsAssetInResources(Application.dataPath + aProjectileFilePath))
        {
            GProjectile aProj = new GProjectile();
            aProj.mPoolCount = aProjectile.mPoolCount;
            aProj.mSpeed     = aProjectile.mSpeed;
            GCircleCollider aCollider  = new GCircleCollider(32.00001f, true);
            GRigidbody      aRigidBody = new GRigidbody();
            GSprite         aSprite    = new GSprite(aProjectile.mDisplaySprite.rect, aProjectile.mProjectileAnimation[0].mTextureAssetGUID,
                                                     aProjectile.mDisplaySprite.texture.height, (int)aProjectile.mRenderLayer);
            StringBuilder aProjectileObject = new StringBuilder("{\n");
            aProjectileObject.Append("\"name\" : \"" + aProjectile.mName + "\",\n");
            aProjectileObject.Append("\"Components\" : [\n");
            aProjectileObject.Append(aSprite.ToString() + ",\n");
            aProjectileObject.Append(aProj.ToString() + ",\n");
            aProjectileObject.Append(aCollider.ToString() + ",\n");
            aProjectileObject.Append(aRigidBody.ToString() + ",\n");
            aProjectileObject.Append("{\n\"class\" : \"Animator\",\n\"Name\" : \"" + aProjectile.mName + "\"\n},\n");
            foreach (AnimationData aData in aProjectile.mProjectileAnimation)
            {
                GAnimation aAnimation = new GAnimation(aData);
                aProjectileObject.Append(aAnimation.ToString() + ",\n");
            }
            aProjectileObject.Remove(aProjectileObject.Length - 2, 2);
            aProjectileObject.Append("]\n");
            aProjectileObject.Append("}\n");
            SaveToFile(aProjectileObject.ToString(), Application.dataPath + aProjectileFilePath);
            SaveToFile(pProjectile.ToString(), Application.dataPath + aProjectileFilePath + ".json");
        }
        if (!IsPathInResources(pResources, pProjectile.mAssetFilePath + ".json"))
        {
            pResources.Append("\"" + pProjectile.mAssetFilePath + ".json\",");
        }
    }
Пример #13
0
    static StringBuilder GetStaticObjectJson(StaticObject pObject, ref StringBuilder pResources)
    {
        StringBuilder aObjectComponents = new StringBuilder();
        GSprite       aSprite           = new GSprite(pObject.mDisplaySprite.rect, pObject.mTextureGUID,
                                                      pObject.mDisplaySprite.texture.height, (int)pObject.mRenderLayer);

        SaveAssetData(GetAssetFromGUID(pObject.mTextureGUID, AssetMetaData.AssetType.TextureAsset), ref pResources);
        aObjectComponents.Append(aSprite.ToString());
        if (pObject.mColliderType == GameScriptable.ColliderType.Box)
        {
            GPolygonCollider aCollider = new GPolygonCollider(pObject.mIsTrigger);
            aObjectComponents.Append(",\n" + aCollider.ToString());
        }
        else if (pObject.mColliderType == GameScriptable.ColliderType.Circle)
        {
            GCircleCollider aCollider = new GCircleCollider(32.00001f, pObject.mIsTrigger);
            aObjectComponents.Append(",\n" + aCollider.ToString());
        }
        return(aObjectComponents);
    }
Пример #14
0
    static int _CreateGSprite(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                GSprite obj = new GSprite();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: GSprite.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #15
0
 public GSquare(eGMyObject eObj, eGStatus eStt, Vector2 Pos, GSprite sprite)
     : base(eObj, eStt, Pos, sprite)
 {
     this.VELOC = new Vector2(1, 1);
 }