Ejemplo n.º 1
0
 public void LoadMap()
 {
     if (mapName.Length > 0)
     {
         BoardEditProxy.GetItemInfo(mapName, PopulateRetrievedInfo);
     }
 }
Ejemplo n.º 2
0
    private void Awake()
    {
        width  = DEF_WIDTH;
        height = DEF_HEIGHT;

        tileMap  = GetComponentInChildren <Tilemap>();
        instance = this;
        //tiles = new TileEditorProxy[width, height];
        grid = GetComponent <Grid>();
    }
Ejemplo n.º 3
0
    void BuildBoardFromFile()
    {
        PlayerMeta player     = BaseSaver.GetPlayer();
        string     world      = "0" + (((int)player.world)).ToString();
        int        lvl        = int.Parse(player.lastDest.Replace("Dest", ""));
        string     currentMap = world + "_" + (lvl < 10 ? "0" : "") + lvl;

        if (player.world == GameMeta.World.candy)
        {
            currentMap += "_0" + (((int)player.faction) + 1).ToString();
        }
        Debug.Log("BuildBoardFromFile: " + currentMap);
        BoardEditProxy.GetItemInfo(currentMap, PopulateRetrievedInfo);
    }
Ejemplo n.º 4
0
    public void SaveMap()
    {
        if (mapName.Length > 0)
        {
            //Debug.Log("Dimensions: " + BoardEditProxy.instance.GetDimensions().ToString());
            BoardEditMeta bMeta = new BoardEditMeta((int)BoardEditProxy.instance.GetDimensions()[0], (int)BoardEditProxy.instance.GetDimensions()[1],
                                                    BoardEditProxy.instance.GetUnits().Where(unt => unt.GetData().GetTeam() == 0).ToArray(),
                                                    BoardEditProxy.instance.GetUnits().Where(unt => unt.GetData().GetTeam() == 1).ToArray(),
                                                    BoardEditProxy.instance.GetSpecialTiles(TileEditTypes.fire).ToArray(),
                                                    BoardEditProxy.instance.GetSpecialTiles(TileEditTypes.snow).ToArray(),
                                                    BoardEditProxy.instance.GetSpecialTiles(TileEditTypes.wall).ToArray(),
                                                    BoardEditProxy.instance.GetSpecialTiles(TileEditTypes.divine).ToArray()
                                                    );

            BoardEditProxy.SaveItemInfo(mapName, JsonUtility.ToJson(bMeta));
        }
    }
Ejemplo n.º 5
0
 public virtual void SnapToCurrentPosition()
 {
     transform.position = BoardEditProxy.GetWorldPosition(data.GetPosition());
 }
Ejemplo n.º 6
0
    public virtual IEnumerator LerpToTile(TileEditorProxy tile, float time)
    {
        Vector3 start = transform.position;
        Vector3 end   = BoardEditProxy.GetWorldPosition(tile.GetPosition());

        /*
         * Right here is where the animation needs to be set
         */
        Animator anim = transform.GetChild(0).GetComponent <Animator>();

        if (anim != null)
        {
            Vector3 theScale = transform.localScale;

            Vector3Int animStart = GetPosition();
            Vector3Int animEnd   = tile.GetPosition();

            Debug.Log("animStart: " + animStart.ToString());
            Debug.Log("animEnd: " + animEnd.ToString());

            Vector3 diff = animEnd - animStart;
            //float turnWait = .1f;

            Debug.Log("Diff: " + diff.ToString());

            if (diff.x > 0)
            {
                Debug.Log("right");
                theScale.x = -1;
                anim.SetBool("IDLE_FRONT_LEFT", false);
                while (anim.GetBool("IDLE_FRONT_LEFT"))
                {
                }
                anim.SetBool("MV_BACK_LEFT", true);
                anim.SetBool("MV_FRONT_LEFT", false);
            }
            else if (diff.x < 0)
            {
                Debug.Log("left");
                theScale.x = 1;
                anim.SetBool("IDLE_FRONT_LEFT", true);
                while (!anim.GetBool("IDLE_FRONT_LEFT"))
                {
                }
                anim.SetBool("MV_BACK_LEFT", false);
                anim.SetBool("MV_FRONT_LEFT", true);
            }
            else
            {
                //Defender is right below or above attacker
                if (diff.y > 0)
                {
                    Debug.Log("up");
                    theScale.x = 1;
                    anim.SetBool("IDLE_FRONT_LEFT", false);
                    while (anim.GetBool("IDLE_FRONT_LEFT"))
                    {
                    }
                    anim.SetBool("MV_BACK_LEFT", true);
                    anim.SetBool("MV_FRONT_LEFT", false);
                }
                else if (diff.y < 0)
                {
                    Debug.Log("down");
                    theScale.x = -1;
                    anim.SetBool("IDLE_FRONT_LEFT", true);
                    while (!anim.GetBool("IDLE_FRONT_LEFT"))
                    {
                    }
                    anim.SetBool("MV_BACK_LEFT", false);
                    anim.SetBool("MV_FRONT_LEFT", true);
                }
            }
            transform.localScale = theScale;
        }
        float timer = 0f;

        while (timer < time)
        {
            //            Debug.Log(transform.position);
            transform.position = Vector3.Lerp(start, end, timer / time);
            timer += Time.deltaTime;
            yield return(0f);
        }

        data.SetPosition(tile.GetPosition());
        tile.CreateSmoke();
    }