private void ConfirmPressed()
    {
        //If the selection is not active, activate it
        if (!active)
        {
            active = true;
        }
        //If the selection is active, confirm the selection
        else if (!confirmed)
        {
            confirmed = true;
            if (current_panel.selectedSprite == "Random")
            {
                selected_fighter = portraits.GetRandomFighter();
            }
            else
            {
                selected_fighter = current_panel.fighter_info;
            }

            BattleLoader.current_loader.fighters[playerNum] = selected_fighter;
        }
        //If the selection is active, and confirmed
        else
        {
            //Check if anyone else is not confirmed yet
            SelectionRig.selection_rig.CheckStart();
        }
    }
    void LoadInfo()
    {
        if (fighter_info == null)
        {
            fighter_info = GetComponent <FighterInfoLoader>().GetFighterInfo();
        }
        foreach (KeyValuePair <string, object> variable in DefaultStats)
        {
            SetVar(variable.Key, variable.Value);
        }

        foreach (VarData variable in fighter_info.variables)
        {
            VarType type = variable.type;
            switch (type)
            {
            case VarType.BOOL:
                SetVar(variable.name, bool.Parse(variable.value));
                break;

            case VarType.FLOAT:
                SetVar(variable.name, float.Parse(variable.value));
                break;

            case VarType.INT:
                SetVar(variable.name, int.Parse(variable.value));
                break;

            default:
                SetVar(variable.name, variable.value);
                break;
            }
        }
    }
Esempio n. 3
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);
                }
            }
        }
    }
Esempio n. 4
0
		protected internal static BattleFighter createMonsterFighterFromBattleProp(MonsterTeam monsterTeam, FighterInfo fighterProps)
		{
			BattleFighter _fighter = createBattleFighterFromBattleProp(monsterTeam, fighterProps);
			MonsterSkillManager = _fighter;
			FighterBuffManager = _fighter;
			return _fighter;
		}
Esempio n. 5
0
 void OnFighterInfoChanged(FighterInfo info)
 {
     if (source == DataInputSource.FIGHTER)
     {
         input.value = getFighterVar(info);
     }
 }
Esempio n. 6
0
    void StartRandomEncounter()
    {
        int         roll = Random.Range(0, 2);
        FighterInfo enemy;

        switch (roll)
        {
        case 0:
            enemy = new FighterInfo(HardcodedEnemies.oversisedWurm);
            break;

        case 1:
            enemy = new FighterInfo(HardcodedEnemies.fatRat);
            break;

        case 2:
            enemy = new FighterInfo(HardcodedEnemies.smallWasp);
            break;

        default:
            enemy = new FighterInfo(HardcodedEnemies.oversisedWurm);
            break;
        }
        uiManager.ShowImportantMessage($"Encountered {enemy.name}!", () => StartEncounter(enemy));
    }
Esempio n. 7
0
    public FighterInfo Clone()
    {
        FighterInfo newInfo = new FighterInfo();

        newInfo.displayName       = displayName;
        newInfo.franchiseIconPath = franchiseIconPath;
        newInfo.css_icon_path     = css_icon_path;
        newInfo.css_portrait_path = css_portrait_path;
        newInfo.action_file_path  = action_file_path;
        newInfo.sprite_info_path  = sprite_info_path;
        newInfo.sound_path        = sound_path;

        newInfo.colorPalettes = new List <FighterPalette>();
        foreach (FighterPalette palette in colorPalettes)
        {
            newInfo.colorPalettes.Add(palette.Clone());
        }

        newInfo.variables = new List <VarData>();
        foreach (VarData var in variables)
        {
            newInfo.variables.Add(var.Clone());
        }

        return(newInfo);
    }
Esempio n. 8
0
		public BattleFighter(BattleTeam ownerTeam, FighterInfo baseProp)
		{
			this.baseProp = baseProp;
			this.dead = false;
			this.stateManager = new FighterStateManager(this);
			this.fighterProp = new BattleFighterPropty(this);
		}
Esempio n. 9
0
    public void AddPanel(FighterInfo info)
    {
        SelectorPanel panel = panels[count];

        panel.SetPortrait(info);
        count++;
    }
Esempio n. 10
0
		protected internal static BattleFighter createHeroFighterFromBattleProp(HeroTeam heroTeam, FighterInfo fighterProps)
		{
			BattleFighter _fighter = createBattleFighterFromBattleProp(heroTeam, fighterProps);
			setHeroSkillManager(_fighter, heroTeam);
			FighterBuffManager = _fighter;
			return _fighter;
		}
 void OnFighterChanged(FighterInfo info)
 {
     Debug.Log("Attempting to populate with sprites but sprites are broken. This needs to be fixed soon", this);
     //List<ImageDefinition> sprites = new List<ImageDefinition>(LegacyEditorData.instance.loadedSpriteInfo.animations);
     //sprite_names = sprites.Select(spriteData => spriteData.ImageName).ToList();
     //sprite_names.Sort();
     //PopulateList(sprite_names);
 }
Esempio n. 12
0
 public void SetPortrait(FighterInfo info)
 {
     fighter_info          = info;
     selectedSprite        = info.cssIconPath;
     bgSprite.enabled      = true;
     portraitSprite.sprite = info.css_icon_sprite;
     active = true;
 }
    public override void execute()
    {
        FighterInfo info = LegacyEditorData.instance.loadedFighter;

        previousValue = info.GetVarByName(fighterVar).value;
        info.GetVarByName(fighterVar).value = nextValue;
        LegacyEditorData.ChangedFighterData(); //Fire the model changed method since we directly modified the fighter data instead of the model itself.
    }
    public override void undo()
    {
        FighterInfo info = LegacyEditorData.instance.loadedFighter;

        info.GetVarByName(fighterVar).value = previousValue;

        LegacyEditorData.ChangedFighterData();
    }
Esempio n. 15
0
        public FighterFightStatus(Fighter fighter, FighterTeamFightStatus team)
        {
            this.fighter = fighter;
            this.Team = team;
            this.Info = fighter.Info.Clone();

            // Calculate idleTime from speed.
            this.SetIdle();
        }
Esempio n. 16
0
 public void addFighter(FighterInfo info, int player_num)
 {
     //Make sure there's room for this fighter by adding nulls in the between slots if necessary
     while (fighters.Count < player_num + 1)
     {
         fighters.Add(null);
     }
     fighters[player_num] = info;
 }
Esempio n. 17
0
 public void LoadFighterList()
 {
     DirectoryInfo[] individualFighters = FileLoader.FighterDir.GetDirectories();
     foreach (DirectoryInfo fighterDir in individualFighters)
     {
         FighterInfo info = FighterInfo.LoadFighterInfoFile(fighterDir.Name);
         infos.Add(info);
         //portraitRig.AddPanel(info);
     }
 }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        FighterInfo fighter = (FighterInfo)target;

        if (GUILayout.Button("Open Fighter Editor"))
        {
            FighterInfoWindow.Open(fighter);
        }
    }
Esempio n. 19
0
 private static void LoadFighterList()
 {
     fightersAvailable = new List <FighterInfo>();
     DirectoryInfo[] individualFighters = FileLoader.FighterDir.GetDirectories();
     foreach (DirectoryInfo fighterDir in individualFighters)
     {
         FighterInfo info = FighterInfo.LoadFighterInfoFile(fighterDir.Name);
         fightersAvailable.Add(info);
     }
 }
Esempio n. 20
0
		public static FighterInfo createFighterFromMsgMonster(BattleSideEnum side, BattleMsgMonster msgMonster)
		{
			FighterInfo _info = new FighterInfo();
			_info.Index = msgMonster.Index;
			_info.BattleSide = side;
			_info.addNormalProp(BattleKeyConstants.BATTLE_KEY_HERO_TEMPLATE, msgMonster.TemplateId);
			_info.addNormalProp(BattleKeyConstants.BATTLE_KEY_HERO_JOB, 1);
			_info.FighterType = FighterType.MONSTER;
			createMonsterDrop(_info, msgMonster.DropMap);
			return _info;
		}
Esempio n. 21
0
    private void InstantiateRow(FighterInfo info)
    {
        GameObject go    = NGUITools.AddChild(grid.gameObject, FighterRowPrefab);
        UILabel    label = go.GetComponent <UILabel>();

        label.text = info.displayName;
        GhettoCSSFighterRow fighterRow = go.GetComponent <GhettoCSSFighterRow>();

        fighterRow.fighter = info;
        children.Add(fighterRow);
    }
Esempio n. 22
0
    private bool LoadFighterFromFile(FileInfo info)
    {
        FighterInfo fInfo = FighterInfo.LoadFighterInfoFile(info.DirectoryName, info.Name);

        if (fInfo != null)
        {
            LoadNewFighter(fInfo);
            return(true);
        }
        return(false);
    }
    public static bool OpenEditor(int instanceId, int line)
    {
        FighterInfo info = EditorUtility.InstanceIDToObject(instanceId) as FighterInfo;

        if (info != null)
        {
            FighterInfoWindow.Open(info);
            return(true);
        }
        return(false);
    }
Esempio n. 24
0
    bool LoadFighter(FileInfo info)
    {
        FighterInfo fInfo = FighterInfo.LoadFighterInfoFile(info.DirectoryName, info.Name);

        if (fInfo != null)
        {
            LegacyEditorData.instance.LoadNewFighter(fInfo);
            return(true);
        }
        return(false);
    }
Esempio n. 25
0
    public void LoadNewFighter(FighterInfo fInfo)
    {
        FighterDirName = fInfo.directory_name;

        loadedFighter    = fInfo;
        loadedActionFile = ActionFile.LoadActionsFromFile(FighterDirName, fInfo.actionFilePath);
        currentAction    = loadedActionFile.GetFirst();
        loadedSpriteInfo = SpriteInfo.LoadSpritesFromFile(FighterDirName, fInfo.spriteInfoPath);
        loadedSpriteInfo.LoadDirectory(FighterDirName, loadedFighter);

        FireModelChange();
    }
Esempio n. 26
0
 public void OnFighterInfoReady(FighterInfo fInfo)
 {
     fighter_info    = fInfo;
     actions_file    = fighter_info.action_file;
     _current_action = new NeutralAction();
     _current_action.SetDynamicAction(actions_file.Get("NeutralAction"));
     if (isInBuilder)
     {
         _current_action.setIsInBuilder(true);
     }
     _current_action.SetUp(getBattleObject());
 }
Esempio n. 27
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.PropertyField(position, property, label, true);
        FighterInfo info = fieldInfo.GetValue(property.serializedObject.targetObject) as FighterInfo;

        if (property.isExpanded)
        {
            if (GUI.Button(new Rect(position.xMin + 30f, position.yMax - 20f, position.width - 30f, 20f), "Load From Text Asset"))
            {
                info.LoadFromTextAsset();
            }
        }
    }
 public void LoadFighter()
 {
     if (json_file != null)
     {
         fighter_info = JsonUtility.FromJson <FighterInfo>(json_file.text);
         gameObject.BroadcastMessage("OnFighterInfoReady", fighter_info);
     }
     else
     {
         fighter_info = FighterInfo.LoadFighterInfoFile(directory, filename);
     }
     fighter_info.LoadDirectory(directory);
 }
Esempio n. 29
0
    public void FightAgainst(FighterInfo _enemy)
    {
        //SerializableVector3 playerPos = GameObject.FindGameObjectWithTag("Player").transform.position;
        PlayerComponent p = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerComponent>();

        //PlayerPrefs.SetString("playerPos", playerPos.ToString());

        //PlayerPrefs.SetString("player", p.Serialize());
        SaveManager.SaveOnCurrentSlot(p.Serialize());

        //PlayerPrefs.Save();
        enemy = _enemy;
        SceneManager.LoadScene("_Encounter");
    }
Esempio n. 30
0
		public static FighterInfo createFighterFromMsgHero(BattleSideEnum side, BattleMsgHero msgHero)
		{
			FighterInfo _info = new FighterInfo();
			_info.Index = msgHero.Index;
			_info.BattleSide = side;
			_info.addNormalProp(BattleKeyConstants.BATTLE_KEY_HERO_TEMPLATE, msgHero.TemplateId);
			_info.addNormalProp(BattleKeyConstants.BATTLE_KEY_HERO_JOB, msgHero.JobId);
			_info.addNormalProp(BattleKeyConstants.BATTLE_KEY_HERO_TYPE, msgHero.HeroType);
			_info.FighterType = FighterType.HERO;
			_info.BattleProperty = msgHero.FighteProp;
			_info.SkillIdList = msgHero.AllSkill;
			_info.ActiveSkillId = msgHero.ActiveSkillId;
			_info.LeaderSkillId = msgHero.LeaderSkill;
			return _info;
		}
Esempio n. 31
0
 private string getFighterVar(FighterInfo info)
 {
     if (varSource == DataInputVarSource.FIELD)
     {
         return((string)info.GetType().GetField(varName).GetValue(info));
     }
     else if (varSource == DataInputVarSource.PROPERTY)
     {
         return((string)info.GetType().GetProperty(varName).GetValue(info));
     }
     else
     {
         return(info.GetVarByName(varName).value);
     }
 }
Esempio n. 32
0
    public static bool LoadFighterCallback(FileInfo file_info)
    {
        FighterInfo fighter_info = JsonUtility.FromJson <FighterInfo>(File.ReadAllText(file_info.FullName));

        if (fighter_info.displayName != null)
        {
            fighter_info.LoadDirectory(file_info.DirectoryName);
            LegacyEditorData.instance.LoadNewFighter(fighter_info);
            return(true);
        }
        else
        {
            PopupWindow.current_popup_manager.OpenInfoBox("Could not find a fighter at " + file_info.Name + " Maybe the file is malformed, or an incorrect json file?");
            return(false);
        }
    }
Esempio n. 33
0
    public void CreateFighter(DirectoryInfo createdDir, FighterInfo templateFighter)
    {
        FighterInfo newInfo;

        if (templateFighter != null)
        {
            newInfo = CloneTemplateFighter(createdDir, templateFighter);
        }
        else
        {
            newInfo = new FighterInfo();
            ActionFile newActions = new ActionFile();
            newActions.Save(Path.Combine(createdDir.FullName, "fighter_actions.json"));
            newInfo.displayName    = directoryName;
            newInfo.directory_name = directoryName;
            newInfo.actionFilePath = "fighter_actions.json";
            newInfo.GenerateDefaultAttributes();
            if (generateActions)
            {
                //TODO Clone default actions here
            }

            if (useSprite)
            {
                DirectoryInfo spriteDir  = Directory.CreateDirectory(Path.Combine(createdDir.FullName, "sprites"));
                SpriteInfo    spriteInfo = new SpriteInfo();

                spriteInfo.spriteDirectory = "sprites";
                spriteInfo.default_sprite  = "idle";
                spriteInfo.costumeName     = "default";

                spriteInfo.Save(Path.Combine(createdDir.FullName, "sprite_info.json"));
                newInfo.sprite_info = spriteInfo;
            }

            if (useModel)
            {
                //TODO create model directory and stuff
            }
        }

        newInfo.Save(Path.Combine(FileLoader.GetFighterDir(directoryName).FullName, "fighter_info.json"));
        newInfo.sprite_info.Save(Path.Combine(createdDir.FullName, "sprite_info.json"));

        LegacyEditorData.instance.LoadNewFighter(newInfo);
        Dispose();
    }
Esempio n. 34
0
 public void OnConfirm()
 {
     if (!directoryName.Equals(""))
     {
         DirectoryInfo newDir = FileLoader.GetFighterDir(directoryName);
         if (!newDir.Exists)
         {
             DirectoryInfo createdDir = Directory.CreateDirectory(newDir.FullName);
             //Permission issues can possibly cause this directory to not exist even after we just made it so we gotta check again
             if (createdDir.Exists)
             {
                 //Copy the template fighter if there is one
                 if (templateFighter != null && templateFighter != "")
                 {
                     FighterInfo templateInfo = FighterInfo.LoadFighterInfoFile(templateFighter);
                     if (templateInfo != null)
                     {
                         CreateFighter(createdDir, templateInfo);
                         //TODO Copy fighter template
                     }
                     else
                     {
                         DisplayError("Could not find an existing Fighter named " + templateFighter + ", are you sure you used the Directory name?");
                     }
                 }
                 else
                 {
                     CreateFighter(createdDir, null);
                     Dispose();
                 }
                 FighterInfo newFighter = new FighterInfo();
             }
             else
             {
                 DisplayError("An issue occurred attempting to create the Fighter directory. Check your system permissions and try again.");
             }
         }
         else
         {
             DisplayError("A fighter already exists with that name");
         }
     }
     else
     {
         DisplayError("Fighter Directory cannot be empty");
     }
 }
    void OnFighterChanged(FighterInfo fighter)
    {
        //Get rid of our old list
        foreach (GameObject child in children)
        {
            NGUITools.Destroy(child);
        }
        children.Clear(); //Empty the list for future use

        //Create all the new
        foreach (FileInfo imageFile in fighter.sprite_info.spriteFiles)
        {
            instantiateButton(imageFile);
        }

        //Realign the grid
        grid.Reposition();
    }
Esempio n. 36
0
    private FighterInfo CloneTemplateFighter(DirectoryInfo createdDir, FighterInfo templateFighter)
    {
        Debug.Log("Cloning Template Fighter");
        FighterInfo   newInfo = templateFighter.Clone();
        DirectoryInfo oldDir  = FileLoader.GetFighterDir(templateFighter.directory_name);

        try {
            FileLoader.CopyDirectory(oldDir.FullName, createdDir.FullName, true);
        } catch {
            DisplayError("Could not find an existing Fighter named " + templateFighter + ", are you sure you used the Directory name?");
        }

        newInfo.displayName    = directoryName;
        newInfo.directory_name = directoryName;
        newInfo.actionFilePath = "fighter_actions.json";

        newInfo.sprite_info = templateFighter.sprite_info;

        return(newInfo);
    }
Esempio n. 37
0
		public static BattleFighter createBattleFighterFromBattleProp(BattleTeam ownerTeam, FighterInfo fighterProp)
		{
			BattleFighter _fighter = new BattleFighter(ownerTeam, fighterProp);
			_fighter.Index = fighterProp.Index;
			_fighter.setOwnerTeam(ownerTeam);
			initFighterActFromFighterProp(_fighter, fighterProp.BattleProperty);
			return _fighter;
		}
Esempio n. 38
0
		protected internal static void setMonsterDrop(int key, FighterInfo info, Dictionary<sbyte, int> dropMap)
		{
			sbyte _byteKey = (sbyte) key;
			if (dropMap.ContainsKey(_byteKey))
			{
				int _dropHero = dropMap[_byteKey];
				info.addNormalProp(key, _dropHero);
			}
		}
Esempio n. 39
0
		public static FighterInfo createFighterProp(int index, BattleSideEnum side, FighterType type, Dictionary<int, int> prop)
		{
			FighterInfo _info = new FighterInfo();
			_info.Index = index;
			_info.BattleProperty = prop;
			_info.BattleSide = side;
			_info.FighterType = type;
			return _info;
		}
Esempio n. 40
0
		protected internal static void createMonsterDrop(FighterInfo info, Dictionary<sbyte, int> dropMap)
		{
			setMonsterDrop(BattleKeyConstants.BATTLE_PROP_MONSTER_DROP_COIN, info, dropMap);
			setMonsterDrop(BattleKeyConstants.BATTLE_PROP_MONSTER_DROP_SPRIT, info, dropMap);
			setMonsterDrop(BattleKeyConstants.BATTLE_PROP_MONSTER_DROP_HERO, info, dropMap);
			setMonsterDrop(BattleKeyConstants.BATTLE_PROP_MONSTER_DROP_ITEM, info, dropMap);
			setMonsterDrop(BattleKeyConstants.BATTLE_PROP_MONSTER_DROP_CHIP, info, dropMap);
		}