Exemple #1
0
    public void SizeToOwner(BattleObject obj)
    {
        float scale = obj.GetFloatVar(TussleConstants.SpriteVariableNames.PIXELS_PER_UNIT);
        //float scale = 50;
        Vector3 positionFromCenter = new Vector3(hitboxRect.center.x / scale, hitboxRect.center.y / scale, -0.1f);

        transform.localPosition = positionFromCenter;
        transform.localScale    = new Vector3(hitboxRect.width / scale, hitboxRect.height / scale, 1.0f);
    }
Exemple #2
0
    public override void Execute(BattleObject obj, GameAction action)
    {
        //Arguments
        float xFactor = (float)GetArgument("xFactor", obj, action, 0);

        //Variables from fighter
        float change_x = obj.GetFloatVar(TussleConstants.MotionVariableNames.XSPEED);
        float xPref    = obj.GetFloatVar(TussleConstants.MotionVariableNames.XPREF);

        //Values from settings
        float friction    = Settings.current_settings.friction_ratio;
        float air_control = Settings.current_settings.aircontrol_ratio;

        if (obj.GetBoolVar(TussleConstants.FighterVariableNames.IS_GROUNDED))
        {
            xFactor = xFactor * friction;
        }
        else
        {
            xFactor = xFactor * air_control;
        }

        if (change_x > xPref)
        {
            float diff = change_x - xPref;
            change_x -= Mathf.Min(diff, xFactor);
        }
        else if (change_x < xPref)
        {
            float diff = xPref - change_x;
            change_x += Mathf.Min(diff, xFactor);
        }

        //Finally, update our actual speed
        obj.SendMessage("ChangeXSpeed", change_x);
    }
Exemple #3
0
    public void SizeToOwner()
    {
        float scale = fighter.GetFloatVar(TussleConstants.SpriteVariableNames.PIXELS_PER_UNIT);

        if (scale == 0)
        {
            Debug.LogWarning("Scale is zero! Setting to 1 instead");
            scale = 1f;
        }
        transform.localScale = new Vector3(1 / scale, 1 / scale, 1.0f);

        //float scale = 50;
        Vector3 newPosition = new Vector3(boxRect.center.x, boxRect.center.y, displayBox.transform.localPosition.z);

        displayBox.transform.localPosition = newPosition;
        displayBox.transform.localScale    = new Vector3(boxRect.width, boxRect.height, 0.1f);
    }
Exemple #4
0
 public object GetData(BattleObject owner, GameAction action)
 {
     if (source == SubactionSource.CONSTANT)
     {
         if (type == SubactionVarType.STRING)
         {
             return(data);
         }
         else if (type == SubactionVarType.INT)
         {
             return(int.Parse(data));
         }
         else if (type == SubactionVarType.FLOAT)
         {
             return(float.Parse(data));
         }
         else if (type == SubactionVarType.BOOL)
         {
             return(bool.Parse(data));
         }
         else
         {
             Debug.LogError("SubactionVarData incorrect type: " + type);
             return(null);
         }
     }
     else if (source == SubactionSource.OWNER)
     {
         if (type == SubactionVarType.STRING)
         {
             return(owner.GetStringVar(data));
         }
         else if (type == SubactionVarType.INT)
         {
             return(owner.GetIntVar(data));
         }
         else if (type == SubactionVarType.FLOAT)
         {
             return(owner.GetFloatVar(data));
         }
         else if (type == SubactionVarType.BOOL)
         {
             return(owner.GetBoolVar(data));
         }
         else
         {
             Debug.LogError("SubactionVarData incorrect type: " + type);
             return(null);
         }
     }
     else if (source == SubactionSource.ACTION)
     {
         if (type == SubactionVarType.STRING)
         {
             return(action.GetStringVar(data));
         }
         else if (type == SubactionVarType.INT)
         {
             return(action.GetIntVar(data));
         }
         else if (type == SubactionVarType.FLOAT)
         {
             return(action.GetFloatVar(data));
         }
         else if (type == SubactionVarType.BOOL)
         {
             return(action.GetBoolVar(data));
         }
         else
         {
             Debug.LogError("SubactionVarData incorrect type: " + type);
             return(null);
         }
     }
     else
     {
         Debug.LogError("SubactionVarData incorrect source: " + source);
         return(null);
     }
 }
Exemple #5
0
    public void MoveAnchorPixel(int centerx, int centery)
    {
        float pixelsPerUnit = parent.GetFloatVar(TussleConstants.SpriteVariableNames.PIXELS_PER_UNIT);

        transform.localPosition = new Vector3(centerx / pixelsPerUnit, centery / pixelsPerUnit, 0.0f);
    }
Exemple #6
0
 public static Vector2 GetDirectionMagnitude(BattleObject actor)
 {
     return(GetDirectionMagnitude(actor.GetFloatVar(TussleConstants.MotionVariableNames.XSPEED), actor.GetFloatVar(TussleConstants.MotionVariableNames.YSPEED)));
 }