playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - brzozowsky

Pages: [1]
1
Share New Actions / Round Float with decimal places
« on: January 18, 2012, 11:29:24 AM »
Round Float with decimal places.

EXAMPLE:
Source Float: < 54.2486234 >
- Result Float with "None" decimal places: < 54 >
- Result Float with "One" decimal places: < 54.2 >
- Result Float with "Two" decimal places: < 54.24 >
- Result Float with "Three" decimal places: < 54.248 >
- Result Float with "Four" decimal places: < 54.2486 >

EDIT: Now you can store the result as a String!


Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved.
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Convert)]
[Tooltip("Round Float with decimal places.")]
public class FloatRound : FsmStateAction
{
public enum Operation
{
None,
One,
Two,
Three,
Four
}
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat floatVariable;
[UIHint(UIHint.Variable)]
public FsmFloat storeFloatResult;
[UIHint(UIHint.Variable)]
public FsmString storeStringResult;
public Operation decimalPlaces = Operation.Two;
public bool everyFrame;
public override void Reset()
{
floatVariable = null;
storeFloatResult = null;
storeStringResult = null;
decimalPlaces = Operation.Two;
everyFrame = false;
}
public override void OnEnter()
{
DoConvertFloat();
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
DoConvertFloat();
}
void DoConvertFloat()
{
if (storeFloatResult != null)
{
switch (decimalPlaces)
{
case Operation.None:
storeFloatResult.Value = Mathf.Round(floatVariable.Value);
break;
case Operation.One:
storeFloatResult.Value = Mathf.Round((floatVariable.Value)*10f)/10f;
break;
case Operation.Two:
storeFloatResult.Value = Mathf.Round((floatVariable.Value)*100f)/100f;
break;
case Operation.Three:
storeFloatResult.Value = Mathf.Round((floatVariable.Value)*1000f)/1000f;
break;
case Operation.Four:
storeFloatResult.Value = Mathf.Round((floatVariable.Value)*10000f)/10000f;
break;
default:
break;
}
}
if (storeStringResult != null)
{
switch (decimalPlaces)
{
case Operation.None:
storeStringResult.Value = floatVariable.Value.ToString ("F" + 0.0);
break;
case Operation.One:
storeStringResult.Value = floatVariable.Value.ToString ("F" + 1.0);
break;
case Operation.Two:
storeStringResult.Value = floatVariable.Value.ToString ("F" + 2.0);
break;
case Operation.Three:
storeStringResult.Value = floatVariable.Value.ToString ("F" + 3.0);
break;
case Operation.Four:
storeStringResult.Value = floatVariable.Value.ToString ("F" + 4.0);
break;
default:
break;
}
}
}
}
}

2
User Showcase / Chrome Memory Game v1.1
« on: January 02, 2012, 06:02:42 PM »
Here is my little project, created in 24 hours. Is a classic memory game for kids.
Developed with Unity3D, Playmaker, 3DSMAX 2012, Photoshop CS6.



You can play this game in your browser or download a hi-res version for your pc on my website: http://brzozowsky.bplaced.net

- Play now in your browser: http://brzozowsky.bplaced.net/?page_id=213
- Download hi-res PC version: http://brzozowsky.bplaced.net/wp-content/uploads/2012/01/setup.rar

- You can watch the developing video here:


3
Playmaker Help / Read PlayerPrefs in new scene?
« on: August 04, 2011, 04:11:20 PM »
I have stored some float values in my first game scene, now i will read the same values in the second game scene. Is it possible? How can i make this?

Pages: [1]