示例#1
0
    /// <summary>
    /// Singleton code. Will destroy any superfluous battle controllers that are in the scenes it loads into.
    /// When the battle processing is done, this object should be destroyed to make room for a new battle.
    /// </summary>
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        if (current_loader == null) //if we don't have a settings object
        {
            current_loader = this;
        }
        else //if it's already set
        {
            current_loader.spawnPoints = spawnPoints; //Set the spawn points to this one's
            Destroy(gameObject); //Destroy the new one
        }

        for (int i = 0; i < fighter_strings.Length; i++)
        {
            if (fighter_strings[i] != "")
            {
                FighterInfo info = FighterInfo.LoadFighterInfoFile(fighter_strings[i]);
                if (info != null)
                {
                    fighters.Add(info);
                }
            }
        }
    }
示例#2
0
 void InitBattle()
 {
     isWalking       = false;
     attacked        = false;
     canGetEncounter = false;
     battleLoader    = GameObject.FindWithTag("GameController").GetComponent <BattleLoader>();
     battleLoader.LoadBattleScene();
 }
示例#3
0
    // Nuke existing data and start fresh (Moved to Initializer)
    public static void ResetData()
    {
        // reset BattleLoader
        BattleLoader.ResetData();

        // reset Shop
        Shop.ResetData();
    }
    // Start is called before the first frame update
    void Start()
    {
        // Load or Reload this dungeon
        BattleLoader.LoadLevel(dungeonLevel);

        // Set gold display
        partyGoldText.text = BattleLoader.Party.Gold.ToString();
    }
示例#5
0
 // Runs the Initializer() method in each static script. The call is ignored if
 // a class has already been initialized.
 public static void Run()
 {
     //AudioManager initialized by GameAudioSource object
     InvData.Initialize();
     BattleEnemyData.Initialize();
     HeroSpriteData.Initialize();
     BattleAbilityData.Initialize();
     BattleLoader.Initialize();
     Shop.Initialize();
     TalkData.Initialize();
 }
示例#6
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Hero_Dungeon"))
        {
            // Refresh info
            SetInfo();

            // Label as dead for the next reload of the scene
            info.IsDead = true;

            // Gather current status of all enemies in the dungeon scene, for reload later
            BattleLoader.UpdatePositions(collision.gameObject);

            // Load a battle based on the name of the creature encountered in the dungeon
            BattleLoader.LoadBattle(info.EnemyName);
        }
    }
    //**************************************************************//
    // Function to draw the options for a battle
    void DrawButtonsOnList(string WWW_REsponse)
    {
        //Delete all buttons from the List
        foreach (GameObject Button in GOButtonList)
        {
            Destroy(Button);
        }

        // Check if there is a valid search
        if (WWW_REsponse.IndexOf("Error report") != 56)
        {
            // parse the JSON from WEB to an Array
            JSONNode N = JSON.Parse(WWW_REsponse);

            // if the list is not empty
            if (N != null)
            {
                for (int i = 0; i < N.Count; i++)
                {
                    // create a new prefab of a buttom and add to the list and to the list of objects
                    GameObject newButton = Instantiate(BattleButton) as GameObject;
                    newButton.transform.parent = ListOfButtons.transform;
                    GOButtonList.Add(newButton);

                    //Position the button using the Battlelist anchor as reference
                    RectTransform Botao = newButton.GetComponents <RectTransform> () [0];
                    Botao.localPosition = new Vector2(0, -10 - Botao.sizeDelta.y * i);
                    //Resize the button
                    Botao.sizeDelta = new Vector2(-20, Botao.sizeDelta.y);

                    // Change the data inside the button
                    Text ButtonText = (Text)newButton.GetComponentInChildren <Text>();
                    ButtonText.text = N[i]["battleTitle"].Value;
                    BattleLoader Loader = (BattleLoader)newButton.GetComponent <BattleLoader>();
                    Loader.BattleID = N[i]["battleID"].Value;
                }
                //get rectransform from the battleList and set a minimal size
                RectTransform Quadradinho = (RectTransform)ListOfButtons.GetComponent <RectTransform>();
                Quadradinho.sizeDelta = new Vector2(Quadradinho.offsetMin.x, 50 * N.Count + 30);
            }
        }
    }