public BattleObject LoadFighter(int player_num)
    {
        GameObject   obj       = new GameObject();
        BattleObject battleObj = obj.AddComponent <BattleObject>();

        if (abstract_fighter_info != null)
        {
            AbstractFighter fighter = obj.AddComponent <AbstractFighter>();
        }
        if (sprite_handler_info != null)
        {
            SpriteHandler sprite = obj.AddComponent <SpriteHandler>();
            //sprite.orientation = sprite_handler_info.orientation;
        }
        if (action_handler_info != null)
        {
            ActionHandler actions = obj.AddComponent <ActionHandler>();
            //actions.action_json = action_handler_info.action_json;
            //actions.starting_action = action_handler_info.starting_action;
        }
        if (motion_handler_info != null)
        {
            MotionHandler mot = obj.AddComponent <MotionHandler>();
        }
        if (ecb_info != null)
        {
            //EnvironmentCollider ecb = obj.AddComponent<EnvironmentCollider>();
        }
        foreach (VarData vardata in variables)
        {
            battleObj.SetVar(vardata.name, vardata.value);
        }
        battleObj.LoadComponents();
        return(battleObj);
    }
Exemplo n.º 2
0
 /// <summary>
 /// Sets the fighter or action variable that this data corresponds to to a given value.
 /// For example, if this SubactionVarData is meant to get the TussleConstants.FighterVariableNames.FACING_DIRECTION variable from fighter, you could use
 /// this function on it and pass it a value to set TussleConstants.FighterVariableNames.FACING_DIRECTION to the given value.
 ///
 /// If called on a "constant" SubactionVarData, this function does nothing.
 /// </summary>
 /// <param name="owner">The BattleObject this is operating on</param>
 /// <param name="action">The action calling this subaction</param>
 /// <param name="value">The data to set the variable</param>
 public void SetVariableInTarget(BattleObject owner, GameAction action, object value)
 {
     if (source == SubactionSource.CONSTANT)
     {
         Debug.LogWarning("SetVariable given a constant instead of a variable");
     }
     else if (source == SubactionSource.OWNER)
     {
         owner.SetVar(data, value);
     }
     else if (source == SubactionSource.ACTION)
     {
         action.SetVar(data, value);
     }
 }
Exemplo n.º 3
0
 void OnFighterChanged(FighterInfo info)
 {
     if (info.action_file != null && info.sprite_info != null)
     {
         fighterObject.SetActive(true);
         fighterObject.SendMessage("OnFighterInfoReady", info);
         SpriteHandler spriteHandler = fighterObject.GetComponent <SpriteHandler>();
         spriteHandler.ChangeAnimation("idle", 0);
         displaySprite = fighterObject.GetComponentInChildren <SpriteRenderer>();
         BattleObject battleObject = fighterObject.GetComponent <BattleObject>();
         foreach (VarData var in info.variables)
         {
             battleObject.SetVar(var.name, var.value);
         }
     }
     else
     {
         Debug.Log("Fighter does not have enough data to be enabled");
         fighterObject.SetActive(false);
     }
 }