Browse Source

Added Animator Parameter commands & fixed parallax

master
chrisgregan 11 years ago
parent
commit
dbae4165aa
  1. 5
      Assets/Fungus/Animation.meta
  2. 0
      Assets/Fungus/Animation/SetAnimBool.cs
  3. 0
      Assets/Fungus/Animation/SetAnimBool.cs.meta
  4. 0
      Assets/Fungus/Animation/SetAnimFloat.cs
  5. 0
      Assets/Fungus/Animation/SetAnimFloat.cs.meta
  6. 0
      Assets/Fungus/Animation/SetAnimInteger.cs
  7. 0
      Assets/Fungus/Animation/SetAnimInteger.cs.meta
  8. 0
      Assets/Fungus/Animation/SetAnimTrigger.cs
  9. 0
      Assets/Fungus/Animation/SetAnimTrigger.cs.meta
  10. BIN
      Assets/Fungus/Sprite/Prefabs/Button.prefab
  11. 4
      Assets/Fungus/Sprite/Prefabs/Button.prefab.meta
  12. BIN
      Assets/Fungus/Sprite/Prefabs/GUIButton.prefab
  13. 4
      Assets/Fungus/Sprite/Prefabs/GUIButton.prefab.meta
  14. 25
      Assets/Fungus/Sprite/Scripts/AnimationListener.cs
  15. 8
      Assets/Fungus/Sprite/Scripts/AnimationListener.cs.meta
  16. 50
      Assets/Fungus/Sprite/Scripts/Parallax.cs
  17. BIN
      Assets/Shuttle/ShuttleGame.unity

5
Assets/Fungus/Animation.meta

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 623a31d1ed64f48c18a2941fb2e6bb4b
folderAsset: yes
DefaultImporter:
userData:

0
Assets/Fungus/Sprite/Commands/SetAnimBool.cs → Assets/Fungus/Animation/SetAnimBool.cs

0
Assets/Fungus/Sprite/Commands/SetAnimBool.cs.meta → Assets/Fungus/Animation/SetAnimBool.cs.meta

0
Assets/Fungus/Sprite/Commands/SetAnimFloat.cs → Assets/Fungus/Animation/SetAnimFloat.cs

0
Assets/Fungus/Sprite/Commands/SetAnimFloat.cs.meta → Assets/Fungus/Animation/SetAnimFloat.cs.meta

0
Assets/Fungus/Sprite/Commands/SetAnimInteger.cs → Assets/Fungus/Animation/SetAnimInteger.cs

0
Assets/Fungus/Sprite/Commands/SetAnimInteger.cs.meta → Assets/Fungus/Animation/SetAnimInteger.cs.meta

0
Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs → Assets/Fungus/Animation/SetAnimTrigger.cs

0
Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs.meta → Assets/Fungus/Animation/SetAnimTrigger.cs.meta

BIN
Assets/Fungus/Sprite/Prefabs/Button.prefab

Binary file not shown.

4
Assets/Fungus/Sprite/Prefabs/Button.prefab.meta

@ -1,4 +0,0 @@
fileFormatVersion: 2
guid: 2830c354320dd41fb8c7fe61f592942c
NativeFormatImporter:
userData:

BIN
Assets/Fungus/Sprite/Prefabs/GUIButton.prefab

Binary file not shown.

4
Assets/Fungus/Sprite/Prefabs/GUIButton.prefab.meta

@ -1,4 +0,0 @@
fileFormatVersion: 2
guid: a55e55be9295f4b9db04d66b1f66612c
NativeFormatImporter:
userData:

25
Assets/Fungus/Sprite/Scripts/AnimationListener.cs

@ -1,25 +0,0 @@
using UnityEngine;
using System.Collections;
namespace Fungus
{
/**
* Listener component to handle animation events.
* Usage:
* 1. Attach this script to the animated sprite that you want to listen to for events.
* 2. Add an event on the animation timeline
* 3. Edit the event and choose the 'CallRoomMethod' function
* 4. In the string parameters box, enter the name of the method to call in the active Room's script.
*/
public class AnimationListener : MonoBehaviour
{
/**
* Handler method for animation events.
* The string event parameter is used to call a named method on the active room class
*/
void CallRoomMethod(string methodName)
{
// TODO: Execute a FungusScript sequence
}
}
}

8
Assets/Fungus/Sprite/Scripts/AnimationListener.cs.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6876254e624e04c9c9e4d2d9edb2901c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

50
Assets/Fungus/Sprite/Scripts/Parallax.cs

@ -5,28 +5,22 @@ namespace Fungus
{
/**
* Attach this component to a sprite object to apply a simple parallax scrolling effect.
* The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the parent Room.
* The scale parallax is calculated based on the ratio of the camera size to the size of the Room. This gives a 'dolly zoom' effect.
* Accelerometer based parallax may also be applied on devices that support it.
* The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the background sprite.
* The scale parallax is calculated based on the ratio of the camera size to the size of the background sprite. This gives a 'dolly zoom' effect.
* Accelerometer based parallax is also applied on devices that support it.
*/
public class Parallax : MonoBehaviour
{
/**
* Scale factor for calculating the parallax offset.
*/
public Vector2 parallaxScale = new Vector2(0.25f, 0f);
/**
* Scale factor when camera is zoomed out to show the full Room.
* This will typically be set to 1 to show the sprite at normal size.
* The background sprite which this sprite is layered on top of.
* The position of this sprite is used to calculate the parallax offset.
*/
public float zoomedOutScale = 1f;
public SpriteRenderer backgroundSprite;
/**
* Scale factor when camera is fully zoomed in on Room.
* Setting this to a value greater than 1 will give a 'dolly zoom' effect when zooming in.
* Scale factor for calculating the parallax offset.
*/
public float zoomedInScale = 1f;
public Vector2 parallaxScale = new Vector2(0.25f, 0f);
/**
* Scale factor for calculating parallax offset based on device accelerometer tilt angle.
@ -35,7 +29,6 @@ namespace Fungus
public float accelerometerScale = 0.5f;
Vector3 startPosition;
// Vector3 startScale;
Vector3 acceleration;
Vector3 velocity;
@ -44,20 +37,33 @@ namespace Fungus
{
// Store the starting position and scale of the sprite object
startPosition = transform.position;
// startScale = transform.localScale;
// Default to using parent sprite as background
if (backgroundSprite == null)
{
backgroundSprite = gameObject.GetComponentInParent<SpriteRenderer>();
}
}
void Update ()
{
if (backgroundSprite == null)
{
return;
}
Vector3 translation = Vector3.zero;
// Apply parallax translation based on camera position relative to Room
// Apply parallax translation based on camera position relative to background sprite
{
Vector3 a = startPosition;
Vector3 a = backgroundSprite.bounds.center;
Vector3 b = Camera.main.transform.position;
translation = (a - b);
translation.x *= parallaxScale.x;
translation.y *= parallaxScale.y;
translation.z = 0;
// TODO: Limit parallax offset to just outside the bounds of the background sprite
}
// Apply parallax translation based on device accelerometer
@ -72,14 +78,6 @@ namespace Fungus
}
transform.position = startPosition + translation;
// Set new scale for sprite
/*
float roomSize = parentRoom.renderer.bounds.extents.y;
float t = Camera.main.orthographicSize / roomSize ;
float scale = Mathf.Lerp (zoomedInScale, zoomedOutScale, t);
transform.localScale = startScale * scale;
*/
}
}
}

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save