BroadcastMessage() public méthode

public BroadcastMessage ( string methodName ) : void
methodName string
Résultat void
Exemple #1
1
 protected void ShotHit(GameObject target)
 {
     if (target != null) { target.BroadcastMessage("TakeDamage", damage); }
 }
    /// <summary>
    /// FixedUpdate del componente
    /// </summary>
    private void FixedUpdate()
    {
        RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
        if (hit.collider != null)
        {
            if (_currentHoverObject != hit.collider.gameObject)
            {
                if (_currentHoverObject != null) {
                     _currentHoverObject.BroadcastMessage("DisableOutline",SendMessageOptions.DontRequireReceiver);
                }
                _currentHoverObject = hit.collider.gameObject;
                //Debug.Log("HoverBegin: " + _currentHoverObject.name);
                // TODO: Llamar a quien le importe HoverBEGIN

				_currentHoverObject.BroadcastMessage("EnableOutline",SendMessageOptions.DontRequireReceiver);
            }
        }
        else
        {
            if (_currentHoverObject != null)
            {
                // TODO: Llamar a quien le importe HoverEND
				_currentHoverObject.BroadcastMessage("DisableOutline",SendMessageOptions.DontRequireReceiver);
                //Debug.Log("HoverEnd: " + _currentHoverObject.name);
                _currentHoverObject = null;
            }
        }
    }
Exemple #3
0
        private void OnParticleCollision(UnityEngine.GameObject other)
        {
            int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
            int i = 0;

            while (i < numCollisionEvents)
            {
                if (Time.time > lastSoundTime + 0.2f)
                {
                    lastSoundTime = Time.time;
                }

                var col = m_CollisionEvents[i].colliderComponent;
                var attachedRigidbody = col.GetComponent <Rigidbody>();
                if (attachedRigidbody != null)
                {
                    Vector3 vel = m_CollisionEvents[i].velocity;
                    attachedRigidbody.AddForce(vel * force, ForceMode.Impulse);
                }

                other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);

                i++;
            }
        }
        private void OnParticleCollision(GameObject other)
        {
            int safeLength = m_ParticleSystem.GetSafeCollisionEventSize();

            if (m_CollisionEvents.Length < safeLength)
            {
                m_CollisionEvents = new ParticleCollisionEvent[safeLength];
            }

            int numCollisionEvents = m_ParticleSystem.GetCollisionEvents(other, m_CollisionEvents);
            int i = 0;

            while (i < numCollisionEvents)
            {
                if (Time.time > lastSoundTime + 0.2f)
                {
                    lastSoundTime = Time.time;
                }

                var col = m_CollisionEvents[i].collider;
                var attachedRigidbody = col.GetComponent<Rigidbody>();
                if (attachedRigidbody != null)
                {
                    Vector3 vel = m_CollisionEvents[i].velocity;
                    attachedRigidbody.AddForce(vel*force, ForceMode.Impulse);
                }

                other.BroadcastMessage("Extinguish", SendMessageOptions.DontRequireReceiver);

                i++;
            }
        }
Exemple #5
0
 IEnumerator ShootAlien(GameObject target)
 {
     BroadcastMessage("OnStartFire");
     target.BroadcastMessage("OnImHit");
     if(xenoWeaponType == XenoWeapon.DamageTypes.FLAME)
         target.BroadcastMessage("OnImOnFire");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     yield return new WaitForSeconds(0.5f);
     target.BroadcastMessage("OnImHit");
     BroadcastMessage("OnStopFire");
     target.BroadcastMessage("OnDeath");
 }
    public void OnCreate( int id )
    {
        Destroy( currentPlayer );

        currentPlayer =  this.InstantiateAsChild( transform, prefabPlayerList[id].gameObject );
        currentPlayer.BroadcastMessage( createdMessage, SendMessageOptions.DontRequireReceiver );
        Debug.Log( createdMessage );
    }
    public static void LoadWorld()
    {
        GameObject.Destroy(GameObject.Find("MenuCamera"));
        if (uLink.Network.isServer)
        {
            IsWhite = true;
        }
        else
        {
            IsWhite = false;
        }

        // disable the wrong spawn
        if (IsWhite)
            GameObject.FindWithTag(Registry.Tag.SpawnBlack).SetActive(false);
        else
            GameObject.FindWithTag(Registry.Tag.SpawnWhite).SetActive(false);

        // player has been instantiated already, so we can get this reference
        Player = GameObject.FindWithTag(Registry.Tag.Player);
        //Debug.Log(Player);

        // camera setup (make sure this comes after the player is loaded)
        CameraTarget = GameObject.Instantiate(Resources.Load(Registry.Prefab.CameraTarget)) as GameObject;
        CameraTarget.BroadcastMessage("SetTarget", Player);

        // land on branch
        if(IsWhite)
        {
            Player.GetComponent<PlayerState>().LandTarget = GameObject.FindGameObjectWithTag(Registry.Tag.SpawnWhite).transform;
        }
        else
        {
            Player.GetComponent<PlayerState>().LandTarget = GameObject.FindGameObjectWithTag(Registry.Tag.SpawnBlack).transform;
        }
        Player.GetComponent<PlayerInput>().SetTrigger(Registry.Animator.Land);

        // if server, load in all objects that must be networked
        if (uLink.Network.isServer)
        {
            Debug.Log("Server load objects");

            uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -873f, 227f), Quaternion.identity, 0);
            uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -873f, -267f), Quaternion.identity, 0);

            // CHASE TEST
            //uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -882f, 0f), Quaternion.identity, 0);
            //uLink.Network.Instantiate(uLink.Network.player, Registry.Prefab.EggProxy, Registry.Prefab.Egg, Registry.Prefab.Egg, new Vector3(-2400f, -882f, 0f), Quaternion.identity, 0);

            // outside
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZone), new Vector3(-1314f, -10f, -637f), Quaternion.identity);

            // torch room
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZoneMini), new Vector3(-2392f, -874f, -232f), Quaternion.identity);
            GameObject.Instantiate(Resources.Load(Registry.Prefab.FireballZoneMini), new Vector3(-2412f, -874f, -232f), Quaternion.identity);
        }
    }
Exemple #8
0
 private void CheckSonarPoint_Enter(GameObject target)
 {
     if (!target.CompareTag("Sonar")) return;
     ColorFader fader = target.GetComponent<ColorFader>();
     if (fader==null) return;
     if (fader.SonarInside()) return;
     Debug.Log("CheckSonarPoint");
     target.BroadcastMessage("OnSonarInside");
 }
Exemple #9
0
 static public int BroadcastMessage(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             self.BroadcastMessage(a1);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(System.Object)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             self.BroadcastMessage(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.SendMessageOptions)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             UnityEngine.SendMessageOptions a2;
             checkEnum(l, 3, out a2);
             self.BroadcastMessage(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             UnityEngine.SendMessageOptions a3;
             checkEnum(l, 4, out a3);
             self.BroadcastMessage(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #10
0
 public static void setTarget(GameObject target, string targetName, int targetType)
 {
     if(Globals.target != null){
         Globals.target.BroadcastMessage("RemoveTarget");
     }
     target.BroadcastMessage("SetTarget");
     Globals.target = target;
     Globals.targetName = targetName;
     Globals.targetType = targetType;
 }
Exemple #11
0
    private int marineCheckCount = 0; //counter to deterine which marine is currently being evaluated for targeting

    #endregion Fields

    #region Methods

    public IEnumerator AttackTarget(GameObject finalMarineTarget)
    {
        gameObject.BroadcastMessage("OnStartFire");
        Debug.Log("attack animation: "+Time.time);
        yield return new WaitForSeconds(0.5f);
        StartCoroutine(BloodSplatter(finalMarineTarget));
        finalMarineTarget.BroadcastMessage("OnBeingAttacked");
        yield return new WaitForSeconds(3.0f);
        unitStatus = UnitStatus.MOVED;
        Debug.Log("done attacking: "+Time.time);
    }
    public static void TargetHit(GameObject objectHit)
    {
        if(objectHit.tag == "TargetToHit")
        {

            //Debug.Log("Target hit: " + objectHit.name + " damage: " + damageDealing);
            objectHit.BroadcastMessage("TagSkade", damageDealing, SendMessageOptions.DontRequireReceiver);
        }
        

    }
 // Methods adjacents
 private void AddJogadores(GameObject obj)
 {
     print("chegouAqui");
     for(int i = 0; i < listaJogadores.Length; i++){
         if(listaJogadores[i] == null){
             listaJogadores[i] = obj;
             obj.BroadcastMessage("AddLayer", i + 10);
                 break;
         }
     }
 }
Exemple #14
0
    // ロード終了時
    //    void OnLevelWasLoaded(int level)
    //    {
    //        Debug.Log("OnLevelWasLoaded : level=" + level + " - " + Application.loadedLevelName);
    // ロード終了時にすると、単体デバッグができないのでStartにしておく
    void Start()
    {
        root = GameObject.Find("/Root");
        ui = GameObject.Find("/UI");

        if (root)
        {
            SetHighScore();
            root.BroadcastMessage("OnFadeOut", gameObject);
        }
        else OnIntermissionEnd();
    }
Exemple #15
0
	// Update is called once per frame
	void Update() {
		RaycastHit info;

		Debug.DrawRay( transform.position, transform.forward, Color.red );

		if ( Physics.Raycast( transform.position, transform.forward, out info, HighlightDistance, gazeLayer ) ) {
			EnableGazeReticle();

			var gazed = info.collider.gameObject;
			if ( gazed != lastGazed ) {
				ignoreGaze = false;
				ResetScale();

				if ( lastGazed != null ) {
					lastGazed.BroadcastMessage( "OnLostGaze", SendMessageOptions.DontRequireReceiver );
				}

				lastGazed = gazed;
				lastGazed.BroadcastMessage( "OnGaze", SendMessageOptions.DontRequireReceiver );
			} else {
				if ( info.distance > GazeDistance ) {
					ignoreGaze = false;
					ResetScale();
					return;
				}

				if ( ignoreGaze ) {
					ResetScale();
					return;
				}

				var scale = Mathf.Min( Gazer.transform.localScale.x + ( Time.deltaTime * ( 1 / GazeTime ) ), 1 );
				Gazer.transform.localScale = new Vector3( scale, 1, scale );

				if ( scale == 1 ) {
					ignoreGaze = true;
					lastGazed.BroadcastMessage( "OnGazed", SendMessageOptions.RequireReceiver );
				}
			}
		} else {
			ignoreGaze = false;

			if ( lastGazed != null ) {
				lastGazed.BroadcastMessage( "OnLostGaze", SendMessageOptions.DontRequireReceiver );
				lastGazed = null;
			}

			if ( ResetScale() ) {
				DisableGazeReticle();
			}
		}
	}
Exemple #16
0
	public void FixedUpdate()
	{
		Control = GameObject.FindWithTag("Controller");
		Nord = GameObject.FindWithTag("Nord");
		Orc = GameObject.FindWithTag("Orc");
		Control.BroadcastMessage("Set");
		if (Vector3.Distance(Nord.transform.position, targetOrc.position) > 4f)
		{
		float step = speed * Time.deltaTime;
		Nord.transform.position = Vector3.MoveTowards(Nord.transform.position, targetOrc.position, step);
		Orc.transform.position = Vector3.MoveTowards(Orc.transform.position, targetNord.position, step);
		}
		else
		{

			animN.CrossFade ("Idle");
			animO.CrossFade ("Idle");

			Control.BroadcastMessage("AttackN1");
			Destroy(this);	
		}
	}
Exemple #17
0
 static public int BroadcastMessage(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.String), typeof(System.Object), typeof(UnityEngine.SendMessageOptions)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             UnityEngine.SendMessageOptions a3;
             checkEnum(l, 4, out a3);
             self.BroadcastMessage(a1, a2, a3);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.String), typeof(System.Object)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             self.BroadcastMessage(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.String)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             self.BroadcastMessage(a1);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.String), typeof(UnityEngine.SendMessageOptions)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             UnityEngine.SendMessageOptions a2;
             checkEnum(l, 3, out a2);
             self.BroadcastMessage(a1, a2);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #18
0
 static public int BroadcastMessage__String(IntPtr l)
 {
     try {
         UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
         System.String          a1;
         checkType(l, 2, out a1);
         self.BroadcastMessage(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #19
0
 public static int BroadcastMessage2_wrap(long L)
 {
     try
     {
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.GameObject obj = get_obj(nThisPtr);
         string arg0 = FCLibHelper.fc_get_string_a(L, 0);
         obj.BroadcastMessage(arg0);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Exemple #20
0
 public static void BroadcastMessage( GameObject sender, string methodName )
 {
     #if DEBUG
     Debug.Log(
         string.Format(
         @"{0}{1}.BroadcastMessage( ""{2}"" );",
         LiveConsoleLogAttribute.Get( LiveConsoleLogAttribute.Attribute.Message ),
         sender.name,
         methodName
         ),
         sender
         );
     #endif
     sender.BroadcastMessage( methodName, SendMessageOptions.DontRequireReceiver );
 }
Exemple #21
0
    static int BroadcastMessage(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(string)))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                obj.BroadcastMessage(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(string), typeof(UnityEngine.SendMessageOptions)))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                UnityEngine.SendMessageOptions arg1 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 3);
                obj.BroadcastMessage(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(string), typeof(object)))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                obj.BroadcastMessage(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(string), typeof(object), typeof(UnityEngine.SendMessageOptions)))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                UnityEngine.SendMessageOptions arg2 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 4);
                obj.BroadcastMessage(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.GameObject.BroadcastMessage"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #22
0
 public static int BroadcastMessage1_wrap(long L)
 {
     try
     {
         long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.GameObject obj = get_obj(nThisPtr);
         string        arg0         = FCLibHelper.fc_get_string_a(L, 0);
         System.Object arg1         = FCGetObj.GetSystemObj(FCLibHelper.fc_get_param_ptr(L, 1));
         obj.BroadcastMessage(arg0, arg1);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
 public void CharacterDied(GameObject character, CharacterType type)
 {
     if (type == CharacterType.Character1) {
         firstActive = false;
     } else if (type == CharacterType.Character2) {
         secondActive = false;
     } else if (type == CharacterType.Character3) {
         thirdActive = false;
     }
     character.BroadcastMessage("CharacterDied");
     CheckForEnemyCountUpdates();
     CheckIfAllCharactersDead();
     if (GameState.activeCharacter.GetComponent<CharacterState>().dead) {
         dyingWithouSwitching = true;
         Invoke("AutoSwitchIfNeeded", 2.0f);
     }
 }
    public void LoadPrefab()
    {
        Helper.SetHideFlags(gameObject, HideFlags.None);

        // delete the old one first
        Helper.DestroyAllChildren(transform, Helper.IsEditMode());

        instance = Instantiate(Prefab);
        instance.name = "instance";
        instance.transform.SetParent(transform);
        instance.transform.localPosition = Vector3.zero;
        instance.transform.localRotation = Quaternion.identity;
        instance.transform.localScale = Prefab.transform.localScale;

        Helper.SetHideFlags(instance.gameObject, HideFlags.HideInHierarchy);

        instance.BroadcastMessage("SetOrientation", Orientation, SendMessageOptions.DontRequireReceiver);
    }
Exemple #25
0
 static public int BroadcastMessage__String__Object__SendMessageOptions(IntPtr l)
 {
     try {
         UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
         System.String          a1;
         checkType(l, 2, out a1);
         System.Object a2;
         checkType(l, 3, out a2);
         UnityEngine.SendMessageOptions a3;
         checkEnum(l, 4, out a3);
         self.BroadcastMessage(a1, a2, a3);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 /// <summary>
 /// 敵との衝突
 /// </summary>
 /// <param name="target">チェック対象</param>
 /// <returns></returns>
 private bool CheckEnemy(GameObject target)
 {
     if (target.CompareTag("Enemy"))
     {
         Debug.Log("CheckEnemy");
         if (owner == OwnerType.Player)
         {
             // 自分の魚雷が敵にヒットしたときだけ、敵の持っているスコアを加算する通知
             target.SendMessage("OnAddScore", SendMessageOptions.DontRequireReceiver);
         }
         else
         {
             // 敵にヒット通知だけ流す
             target.BroadcastMessage("OnHit");
         }
         return true;
     }
     return false;
 }
    // Use this for initialization
    void Start()
    {
        Debug.Log ("START");

        if(Settings.position == Settings.Position.Center)
        {
            Debug.Log ("CENTER");
            GameObject.Find("Main Camera-centerL").gameObject.SetActive(true);
            GameObject.Find("Main Camera-centerR").gameObject.SetActive(true);
            GameObject.Find("Main Camera-leftL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-leftR").gameObject.SetActive(false);
            GameObject.Find("Main Camera-rightL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-rightR").gameObject.SetActive(false);
        }
        if(Settings.position == Settings.Position.Left)
        {
            Debug.Log ("LEFT");
            GameObject.Find("Main Camera-centerL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-centerR").gameObject.SetActive(false);
            GameObject.Find("Main Camera-leftL").gameObject.SetActive(true);
            GameObject.Find("Main Camera-leftR").gameObject.SetActive(true);
            GameObject.Find("Main Camera-rightL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-rightR").gameObject.SetActive(false);
        }
        if(Settings.position == Settings.Position.Right)
        {
            Debug.Log ("RIGHT");
            GameObject.Find("Main Camera-centerL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-centerR").gameObject.SetActive(false);
            GameObject.Find("Main Camera-leftL").gameObject.SetActive(false);
            GameObject.Find("Main Camera-leftR").gameObject.SetActive(false);
            GameObject.Find("Main Camera-rightL").gameObject.SetActive(true);
            GameObject.Find("Main Camera-rightR").gameObject.SetActive(true);
        }

        //OSCHandler.Instance.Init(); //(re?)init OSC
        gob = GameObject.Find("MainPlayer");
        gob.transform.Rotate(0f,180f,0f);
        gob.transform.position = transform.position;
        gob.BroadcastMessage("FadeIn");
        gob.GetComponentInChildren<FadeAndTeleport>().enabled = true;
    }
Exemple #28
0
    public void click()
    {
        // this is uses to see what the player has clicked on and initate action

        //create a ray that shoots what ever the player touches
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit thingIHit;							// the object the ray hits
        if(Physics.Raycast(ray, out thingIHit, 200f))	// shoot the ray and see if it hits anything
        {
            // see what the ray has hit
            switch(thingIHit.transform.gameObject.tag)
            {
            case "tile":
                // the player is touching a tile

                SelectedThing = thingsToSelect.tile;							// set the currently settected object
                if(thingIHit.transform.gameObject.GetComponent<Tile>().Active)	// if the tile is one that can be moved to
                    Movement.move(ActiveUnit, thingIHit.transform.gameObject);	// Initiate the move command on the active unit

                // old code
                //thingIHit.transform.gameObject.renderer.material = glow;
                //thingIHit.transform.gameObject.BroadcastMessage("Activate");
                //Instantiate(cube, new Vector3(thingIHit.transform.position.x, thingIHit.transform.position.y + 10f, thingIHit.transform.position.z), Quaternion.identity);
                break;

            case "cube":
                // the player has touched a unit
                ActiveUnit.BroadcastMessage("NoLongerSelected");	// de sellect the previous active Unit

                ActiveUnit = thingIHit.transform.gameObject;		// set the newly selected object to the active unit
                ActiveUnit.BroadcastMessage("YouAreSelected");		// tell the unit it has been selected

                SelectedThing = thingsToSelect.cube;				//set the currently selected type to cube
                break;
            }
        }
    }
        private void DoActivateTrigger()
        {
            triggerCount--;

            if (triggerCount == 0 || repeatTrigger)
            {
                Object    currentTarget   = target ?? gameObject;
                Behaviour targetBehaviour = currentTarget as Behaviour;
                UnityEngine.GameObject targetGameObject = currentTarget as UnityEngine.GameObject;
                if (targetBehaviour != null)
                {
                    targetGameObject = targetBehaviour.gameObject;
                }

                switch (action)
                {
                case Mode.Trigger:
                    if (targetGameObject != null)
                    {
                        targetGameObject.BroadcastMessage("DoActivateTrigger");
                    }
                    break;

                case Mode.Replace:
                    if (source != null)
                    {
                        if (targetGameObject != null)
                        {
                            Instantiate(source, targetGameObject.transform.position,
                                        targetGameObject.transform.rotation);
                            DestroyObject(targetGameObject);
                        }
                    }
                    break;

                case Mode.Activate:
                    if (targetGameObject != null)
                    {
                        targetGameObject.SetActive(true);
                    }
                    break;

                case Mode.Enable:
                    if (targetBehaviour != null)
                    {
                        targetBehaviour.enabled = true;
                    }
                    break;

                case Mode.Animate:
                    if (targetGameObject != null)
                    {
                        targetGameObject.GetComponent <Animation>().Play();
                    }
                    break;

                case Mode.Deactivate:
                    if (targetGameObject != null)
                    {
                        targetGameObject.SetActive(false);
                    }
                    break;
                }
            }
        }
Exemple #30
0
        /// <summary>
        /// Applies to gameObject any custom X-UniTMX properties present on obj
        /// </summary>
        /// <param name="gameObject">GameObject to apply custom properties to</param>
        /// <param name="obj">MapObject to read custom properties from</param>
        public void ApplyCustomProperties(GameObject gameObject, MapObject obj)
        {
            // nothing to do here...
            if (gameObject == null || obj == null)
                return;

            // Set a layer number for gameObject
            if (obj.HasProperty(Property_Layer))
                gameObject.layer = obj.GetPropertyAsInt(Property_Layer);

            if (obj.HasProperty(Property_LayerName))
                gameObject.layer = LayerMask.NameToLayer(obj.GetPropertyAsString(Property_LayerName));

            // Add a tag for gameObject
            if (obj.HasProperty(Property_Tag))
                gameObject.tag = obj.GetPropertyAsString(Property_Tag);
            // Add Components for this gameObject
            int c = 1;
            while (obj.HasProperty(Property_AddComponent + c))
            {
                UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObject, "Assets/X-UniTMX/Code/Map.cs (2684,5)", obj.GetPropertyAsString(Property_AddComponent + c));
                c++;
            }
            c = 1;
            while (obj.HasProperty(Property_SendMessage + c))
            {
                string messageToSend = obj.GetPropertyAsString(Property_SendMessage + c);
                string[] menssage = messageToSend.Split('|');
                if (menssage.Length == 2)
                {
                    gameObject.BroadcastMessage(menssage[0], menssage[1]);
                }
                if (menssage.Length == 1)
                {
                    gameObject.BroadcastMessage(menssage[0]);
                }
                c++;
            }

            if (gameObject.GetComponent<Renderer>() != null)
            {
                if (obj.HasProperty(Property_SortingLayerName))
                    gameObject.GetComponent<Renderer>().sortingLayerName = obj.GetPropertyAsString(Property_SortingLayerName);

                if (obj.HasProperty(Property_SortingOrder))
                    gameObject.GetComponent<Renderer>().sortingOrder = obj.GetPropertyAsInt(Property_SortingOrder);

                if (obj.HasProperty(Property_SetMaterialColor))
                {
                    string[] splitColor = obj.GetPropertyAsString(Property_SetMaterialColor).Split(',');
                    if (splitColor.Length >= 1)
                    {
                        gameObject.GetComponent<Renderer>().material = new Material(BaseTileMaterial);
                        gameObject.GetComponent<Renderer>().material.color = new Color32(
                            ((byte)(int.Parse(string.IsNullOrEmpty(splitColor[0]) ? "255" : splitColor[0]))),
                            splitColor.Length >= 2 ? ((byte)(int.Parse(splitColor[1]))) : (byte)255,
                            splitColor.Length >= 3 ? ((byte)(int.Parse(splitColor[2]))) : (byte)255,
                            splitColor.Length >= 4 ? ((byte)(int.Parse(splitColor[3]))) : (byte)255);
                    }
                }
            }
        }
    static int BroadcastMessage(IntPtr L)
    {
        IntPtr L0 = LuaException.L;

        try
        {
            ++LuaException.SendMsgCount;
            LuaException.L = L;
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                obj.BroadcastMessage(arg0);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, UnityEngine.SendMessageOptions>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                UnityEngine.SendMessageOptions arg1 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 3);
                obj.BroadcastMessage(arg0, arg1);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, object>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                obj.BroadcastMessage(arg0, arg1);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <string, object, UnityEngine.SendMessageOptions>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                UnityEngine.SendMessageOptions arg2 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 4);
                obj.BroadcastMessage(arg0, arg1, arg2);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else
            {
                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.GameObject.BroadcastMessage"));
            }
        }
        catch (Exception e)
        {
            --LuaException.SendMsgCount;
            LuaException.L = L0;
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int QPYX_BroadcastMessage_YXQP(IntPtr L_YXQP)
    {
        IntPtr L0_YXQP = LuaException.L;

        try
        {
            ++LuaException.SendMsgCount;
            LuaException.L = L_YXQP;
            int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);

            if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <string>(L_YXQP, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject));
                string QPYX_arg0_YXQP      = ToLua.ToString(L_YXQP, 2);
                obj.BroadcastMessage(QPYX_arg0_YXQP);

                if (LuaDLL.lua_toboolean(L_YXQP, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L_YXQP, -1);
                    LuaDLL.lua_pop(L_YXQP, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0_YXQP;
                return(0);
            }
            else if (QPYX_count_YXQP == 3 && TypeChecker.CheckTypes <string, UnityEngine.SendMessageOptions>(L_YXQP, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject));
                string QPYX_arg0_YXQP      = ToLua.ToString(L_YXQP, 2);
                UnityEngine.SendMessageOptions QPYX_arg1_YXQP = (UnityEngine.SendMessageOptions)ToLua.ToObject(L_YXQP, 3);
                obj.BroadcastMessage(QPYX_arg0_YXQP, QPYX_arg1_YXQP);

                if (LuaDLL.lua_toboolean(L_YXQP, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L_YXQP, -1);
                    LuaDLL.lua_pop(L_YXQP, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0_YXQP;
                return(0);
            }
            else if (QPYX_count_YXQP == 3 && TypeChecker.CheckTypes <string, object>(L_YXQP, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject));
                string QPYX_arg0_YXQP      = ToLua.ToString(L_YXQP, 2);
                object QPYX_arg1_YXQP      = ToLua.ToVarObject(L_YXQP, 3);
                obj.BroadcastMessage(QPYX_arg0_YXQP, QPYX_arg1_YXQP);

                if (LuaDLL.lua_toboolean(L_YXQP, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L_YXQP, -1);
                    LuaDLL.lua_pop(L_YXQP, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0_YXQP;
                return(0);
            }
            else if (QPYX_count_YXQP == 4 && TypeChecker.CheckTypes <string, object, UnityEngine.SendMessageOptions>(L_YXQP, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.GameObject));
                string QPYX_arg0_YXQP      = ToLua.ToString(L_YXQP, 2);
                object QPYX_arg1_YXQP      = ToLua.ToVarObject(L_YXQP, 3);
                UnityEngine.SendMessageOptions QPYX_arg2_YXQP = (UnityEngine.SendMessageOptions)ToLua.ToObject(L_YXQP, 4);
                obj.BroadcastMessage(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP);

                if (LuaDLL.lua_toboolean(L_YXQP, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L_YXQP, -1);
                    LuaDLL.lua_pop(L_YXQP, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0_YXQP;
                return(0);
            }
            else
            {
                --LuaException.SendMsgCount;
                LuaException.L = L0_YXQP;
                return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.GameObject.BroadcastMessage"));
            }
        }
        catch (Exception e)
        {
            --LuaException.SendMsgCount;
            LuaException.L = L0_YXQP;
            return(LuaDLL.toluaL_exception(L_YXQP, e));
        }
    }
 public void SendSuccessMessage(GameObject attacker, AttackEffects effect)
 {
     attacker.BroadcastMessage("AttackSuccess", new System.Object[] { this.gameObject, (int)effect});
 }
    void Initialize()
    {
        shape = root.GetComponent<RootElement>().shape;
        lastNumerator = numerator;
        lastDenominator = denominator;
        lastPartitions = partitions;
        prefab = Workspace.Instance.setSourceHeart;
        switch (type)
        {
            case ElementsType.HeartSet:
                prefab = Workspace.Instance.setSourceHeart;
                break;
            case ElementsType.MoonSet:
                prefab = Workspace.Instance.setSourceMoon;
                break;
            case ElementsType.StarSet:
                prefab = Workspace.Instance.setSourceStar;
                break;
        }

        element = GameObject.Instantiate(prefab) as GameObject;

        element.name = "elem_0";
        element.transform.parent = transform;
        element.AddComponent<EmptyElement>();
        element.BroadcastMessage("SetMode", mode, SendMessageOptions.DontRequireReceiver);
        element.BroadcastMessage("SetType", type, SendMessageOptions.DontRequireReceiver);
        element.BroadcastMessage("SetSize", new Vector2(width, height), SendMessageOptions.DontRequireReceiver);
        element.renderer.materials[1].color = strokeColorAlpha;

        fillMat = new List<Material>();
        strokeMat = new List<Material>();

          /*  matInstance0 = GameObject.Instantiate(element.renderer.sharedMaterials[0]) as Material;
        matInstance1 = GameObject.Instantiate(element.renderer.sharedMaterials[1]) as Material;

        fillMat.Add(matInstance0);
        strokeMat.Add(matInstance1);

        element.renderer.materials[0] = fillMat[fillMat.Count - 1];
        element.renderer.materials[1] = strokeMat[strokeMat.Count - 1];*/

        //element.renderer.sharedMaterials[0] = fillMat[fillMat.Count - 1];
        // element.renderer.sharedMaterials[1] = strokeMat[strokeMat.Count - 1];

        /* for (int i = 0; i < element.transform.childCount; i++)
         {
             if (element.transform.GetChild(i).tag == "filling")
                 fillRenderer = element.transform.GetChild(i).renderer;
         }

         foreach (MeshRenderer mr in element.GetComponentsInChildren<MeshRenderer>(true))
         {
             if (mr.gameObject.tag == "stroke")
                 mr.gameObject.SetActive(false);
         }*/

        elements.Add(element);
        singleWidth = element.GetComponent<EmptyElement>().width;
        singleHeight = element.GetComponent<EmptyElement>().height;
        width = element.GetComponent<EmptyElement>().width;
        element.transform.position = transform.TransformPoint(new Vector3(0, 0, 0));
        InitializeStroke();

        if (denominator > 0)
        {
            UpdateDenominator(denominator);
            UpdateNumerator(numerator);
            UpdateDenominatorByPartition(partitions);
            UpdateNumeratorByPartition(partitions, lastPartitions);
        }
    }
Exemple #35
0
    public static void update()
    {
        if(frameRendered != Time.frameCount){ // make sure update is only called once per frame
        init();

        dtEstimated = Time.realtimeSinceStartup - previousRealTime;
        if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large
            dtEstimated = 0.2f;
        previousRealTime = Time.realtimeSinceStartup;
        dtActual = Time.deltaTime*Time.timeScale;
        // if(tweenMaxSearch>1500)
        // 	Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens);
        for( int i = 0; i < tweenMaxSearch && i < maxTweens; i++){

            //Debug.Log("tweens["+i+"].toggle:"+tweens[i].toggle);
            if(tweens[i].toggle){
                tween = tweens[i];
                trans = tween.trans;
                timeTotal = tween.time;
                tweenAction = tween.type;

                dt = dtActual;
                if( tween.useEstimatedTime ){
                    dt = dtEstimated;
                    timeTotal = tween.time;
                }else if( tween.useFrames ){
                    dt = 1;
                }else if(tween.direction==0f){
                    dt = 0f;
                }

                if(trans==null){
                    removeTween(i);
                    continue;
                }
                // Debug.Log("i:"+i+" tween:"+tween+" dt:"+dt);

                // Check for tween finished
                isTweenFinished = false;
                if(tween.delay<=0){
                    if((tween.passed + dt > timeTotal && tween.direction > 0.0f )){
                        isTweenFinished = true;
                        tween.passed = tween.time; // Set to the exact end time so that it can finish tween exactly on the end value
                    }else if(tween.direction<0.0f && tween.passed - dt < 0.0f){
                        isTweenFinished = true;
                        tween.passed = Mathf.Epsilon;
                    }
                }

                if(!tween.hasInitiliazed && ((tween.passed==0.0 && tween.delay==0.0) || tween.passed>0.0) ){
                    tween.hasInitiliazed = true;

                    // Set time based on current timeScale
                    if( !tween.useEstimatedTime ){
                        tween.time = tween.time*Time.timeScale;
                    }

                    // Initialize From Values
                    switch(tweenAction){
                        case TweenAction.MOVE:
                            tween.from = trans.position; break;
                        case TweenAction.MOVE_X:
                            tween.from.x = trans.position.x; break;
                        case TweenAction.MOVE_Y:
                            tween.from.x = trans.position.y; break;
                        case TweenAction.MOVE_Z:
                            tween.from.x = trans.position.z; break;
                        case TweenAction.MOVE_LOCAL_X:
                            tweens[i].from.x = trans.localPosition.x; break;
                        case TweenAction.MOVE_LOCAL_Y:
                            tweens[i].from.x = trans.localPosition.y; break;
                        case TweenAction.MOVE_LOCAL_Z:
                            tweens[i].from.x = trans.localPosition.z; break;
                        case TweenAction.SCALE_X:
                            tween.from.x = trans.localScale.x; break;
                        case TweenAction.SCALE_Y:
                            tween.from.x = trans.localScale.y; break;
                        case TweenAction.SCALE_Z:
                            tween.from.x = trans.localScale.z; break;
                        case TweenAction.ALPHA:
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                                tween.from.x = trans.gameObject.renderer.material.color.a;
                                break;
                            #else
                                SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
                                if(ren!=null){
                                    tween.from.x = ren.color.a;
                                }else if(trans.gameObject.renderer!=null){
                                    tween.from.x = trans.gameObject.renderer.material.color.a;
                                }
                                break;
                            #endif
                        case TweenAction.MOVE_LOCAL:
                            tween.from = trans.localPosition; break;
                        case TweenAction.MOVE_CURVED:
                        case TweenAction.MOVE_CURVED_LOCAL:
                        case TweenAction.MOVE_SPLINE:
                        case TweenAction.MOVE_SPLINE_LOCAL:
                            tween.from.x = 0; break;
                        case TweenAction.ROTATE:
                            tween.from = trans.eulerAngles;
                            tween.to = new Vector3(LeanTween.closestRot( tween.from.x, tween.to.x), LeanTween.closestRot( tween.from.y, tween.to.y), LeanTween.closestRot( tween.from.z, tween.to.z));
                            break;
                        case TweenAction.ROTATE_X:
                            tween.from.x = trans.eulerAngles.x;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_Y:
                            tween.from.x = trans.eulerAngles.y;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_Z:
                            tween.from.x = trans.eulerAngles.z;
                            tween.to.x = LeanTween.closestRot( tween.from.x, tween.to.x);
                            break;
                        case TweenAction.ROTATE_AROUND:
                            tween.lastVal = 0.0f; // optional["last"]
                            tween.from.x = 0.0f;
                            tween.origRotation = trans.rotation; // optional["origRotation"
                            break;
                        case TweenAction.ROTATE_AROUND_LOCAL:
                            tween.lastVal = 0.0f; // optional["last"]
                            tween.from.x = 0.0f;
                            tween.origRotation = trans.localRotation; // optional["origRotation"
                            break;
                        case TweenAction.ROTATE_LOCAL:
                            tween.from = trans.localEulerAngles;
                            tween.to = new Vector3(LeanTween.closestRot( tween.from.x, tween.to.x), LeanTween.closestRot( tween.from.y, tween.to.y), LeanTween.closestRot( tween.from.z, tween.to.z));
                            break;
                        case TweenAction.SCALE:
                            tween.from = trans.localScale; break;
                        case TweenAction.GUI_MOVE:
                            tween.from = new Vector3(tween.ltRect.rect.x, tween.ltRect.rect.y, 0); break;
                        case TweenAction.GUI_MOVE_MARGIN:
                            tween.from = new Vector2(tween.ltRect.margin.x, tween.ltRect.margin.y); break;
                        case TweenAction.GUI_SCALE:
                            tween.from = new  Vector3(tween.ltRect.rect.width, tween.ltRect.rect.height, 0); break;
                        case TweenAction.GUI_ALPHA:
                            tween.from.x = tween.ltRect.alpha; break;
                        case TweenAction.GUI_ROTATE:
                            if(tween.ltRect.rotateEnabled==false){
                                tween.ltRect.rotateEnabled = true;
                                tween.ltRect.resetForRotation();
                            }

                            tween.from.x = tween.ltRect.rotation; break;
                        case TweenAction.ALPHA_VERTEX:
                            tween.from.x = trans.GetComponent<MeshFilter>().mesh.colors32[0].a;
                            break;
                        case TweenAction.CALLBACK_COLOR:
                            tween.diff = new Vector3(1.0f,0.0f,0.0f);
                            break;
                        case TweenAction.COLOR:
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                                if(trans.gameObject.renderer){
                                    Color col = trans.gameObject.renderer.material.color;
                                    tween.from = new Vector3(0.0f, col.a, 0.0f);
                                    tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                    tween.axis = new Vector3( col.r, col.g, col.b );
                                }
                            #else
                                SpriteRenderer ren2 = trans.gameObject.GetComponent<SpriteRenderer>();
                                if(ren2!=null){
                                    tween.from = new Vector3(0.0f, ren2.color.a, 0.0f);
                                    tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                    tween.axis = new Vector3( ren2.color.r, ren2.color.g, ren2.color.b );
                                }else if(trans.gameObject.renderer!=null){
                                    if(trans.gameObject.renderer){
                                        Color col = trans.gameObject.renderer.material.color;
                                        tween.from = new Vector3(0.0f, col.a, 0.0f);
                                        tween.diff = new Vector3(1.0f,0.0f,0.0f);
                                        tween.axis = new Vector3( col.r, col.g, col.b );
                                    }
                                }
                            #endif
                            break;
                    }
                    if(tweenAction!=TweenAction.CALLBACK_COLOR && tweenAction!=TweenAction.COLOR)
                        tween.diff = tween.to - tween.from;
                }
                if(tween.delay<=0){
                    // Move Values
                    if(timeTotal<=0f){
                        //Debug.LogError("time total is zero Time.timeScale:"+Time.timeScale+" useEstimatedTime:"+tween.useEstimatedTime);
                        ratioPassed = 0f;
                    }else{
                        ratioPassed = tween.passed / timeTotal;
                    }

                    if(ratioPassed>1.0f){
                        ratioPassed = 1.0f;
                    }else if(ratioPassed<0f){
                        ratioPassed = 0f;
                    }
                    // Debug.Log("action:"+tweenAction+" ratioPassed:"+ratioPassed + " timeTotal:" + timeTotal + " tween.passed:"+ tween.passed +" dt:"+dt);

                    if(tweenAction>=TweenAction.MOVE_X && tweenAction<=TweenAction.CALLBACK){
                        if(tween.animationCurve!=null){
                            val = tweenOnCurve(tween, ratioPassed);
                        }else {
                            switch( tween.tweenType ){
                                case LeanTweenType.linear:
                                    val = tween.from.x + tween.diff.x * ratioPassed; break;
                                case LeanTweenType.easeOutQuad:
                                    val = easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInQuad:
                                    val = easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuad:
                                    val = easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
                                case LeanTweenType.easeInCubic:
                                    val = easeInCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutCubic:
                                    val = easeOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutCubic:
                                    val = easeInOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInQuart:
                                    val = easeInQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutQuart:
                                    val = easeOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuart:
                                    val = easeInOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInQuint:
                                    val = easeInQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutQuint:
                                    val = easeOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutQuint:
                                    val = easeInOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInSine:
                                    val = easeInSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutSine:
                                    val = easeOutSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutSine:
                                    val = easeInOutSine(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInExpo:
                                    val = easeInExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutExpo:
                                    val = easeOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutExpo:
                                    val = easeInOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInCirc:
                                    val = easeInCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutCirc:
                                    val = easeOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutCirc:
                                    val = easeInOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInBounce:
                                    val = easeInBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutBounce:
                                    val = easeOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutBounce:
                                    val = easeInOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInBack:
                                    val = easeInBack(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutBack:
                                    val = easeOutBack(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutBack:
                                    val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInElastic:
                                    val = easeInElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeOutElastic:
                                    val = easeOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.easeInOutElastic:
                                    val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed); break;
                                case LeanTweenType.punch:
                                case LeanTweenType.easeShake:
                                    if(tween.tweenType==LeanTweenType.punch){
                                        tween.animationCurve = LeanTween.punch;
                                    }else if(tween.tweenType==LeanTweenType.easeShake){
                                        tween.animationCurve = LeanTween.shake;
                                    }
                                    tween.to.x = tween.from.x + tween.to.x;
                                    tween.diff.x = tween.to.x - tween.from.x;
                                    val = tweenOnCurve(tween, ratioPassed); break;
                                case LeanTweenType.easeSpring:
                                    val = spring(tween.from.x, tween.to.x, ratioPassed); break;
                                default:
                                    {
                                        val = tween.from.x + tween.diff.x * ratioPassed; break;
                                    }
                            }

                        }

                        //Debug.Log("from:"+from+" to:"+to+" val:"+val+" ratioPassed:"+ratioPassed);
                        if(tweenAction==TweenAction.MOVE_X){
                            trans.position=new Vector3( val,trans.position.y,trans.position.z);
                        }else if(tweenAction==TweenAction.MOVE_Y){
                            trans.position =new Vector3( trans.position.x,val,trans.position.z);
                        }else if(tweenAction==TweenAction.MOVE_Z){
                            trans.position=new Vector3( trans.position.x,trans.position.y,val);
                        }if(tweenAction==TweenAction.MOVE_LOCAL_X){
                            trans.localPosition=new Vector3( val,trans.localPosition.y,trans.localPosition.z);
                        }else if(tweenAction==TweenAction.MOVE_LOCAL_Y){
                            trans.localPosition=new Vector3( trans.localPosition.x,val,trans.localPosition.z);
                        }else if(tweenAction==TweenAction.MOVE_LOCAL_Z){
                            trans.localPosition=new Vector3( trans.localPosition.x,trans.localPosition.y,val);
                        }else if(tweenAction==TweenAction.MOVE_CURVED){
                            if(tween.path.orientToPath){
                                tween.path.place( trans, val );
                            }else{
                                trans.position = tween.path.point( val );
                            }
                            // Debug.Log("val:"+val+" trans.position:"+trans.position + " 0:"+ tween.curves[0] +" 1:"+tween.curves[1] +" 2:"+tween.curves[2] +" 3:"+tween.curves[3]);
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_CURVED_LOCAL){
                            if(tween.path.orientToPath){
                                tween.path.placeLocal( trans, val );
                            }else{
                                trans.localPosition = tween.path.point( val );
                            }
                            // Debug.Log("val:"+val+" trans.position:"+trans.position);
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_SPLINE){
                            if(tween.spline.orientToPath){
                                tween.spline.place( trans, val );
                            }else{
                                trans.position = tween.spline.point( val );
                            }
                        }else if((TweenAction)tweenAction==TweenAction.MOVE_SPLINE_LOCAL){
                            if(tween.spline.orientToPath){
                                tween.spline.placeLocal( trans, val );
                            }else{
                                trans.localPosition = tween.spline.point( val );
                            }
                        }else if(tweenAction==TweenAction.SCALE_X){
                            trans.localScale=new Vector3(val, trans.localScale.y,trans.localScale.z);
                        }else if(tweenAction==TweenAction.SCALE_Y){
                            trans.localScale=new Vector3( trans.localScale.x,val,trans.localScale.z);
                        }else if(tweenAction==TweenAction.SCALE_Z){
                            trans.localScale=new Vector3(trans.localScale.x,trans.localScale.y,val);
                        }else if(tweenAction==TweenAction.ROTATE_X){
                            trans.eulerAngles=new Vector3(val, trans.eulerAngles.y,trans.eulerAngles.z);
                        }else if(tweenAction==TweenAction.ROTATE_Y){
                            trans.eulerAngles=new Vector3(trans.eulerAngles.x,val,trans.eulerAngles.z);
                        }else if(tweenAction==TweenAction.ROTATE_Z){
                            trans.eulerAngles=new Vector3(trans.eulerAngles.x,trans.eulerAngles.y,val);
                        }else if(tweenAction==TweenAction.ROTATE_AROUND){

                            float move = val -  tween.lastVal;
                            // Debug.Log("move:"+move+" val:"+val + " timeTotal:"+timeTotal + " from:"+tween.from+ " diff:"+tween.diff);
                            if(isTweenFinished){
                                if(tween.direction>0){
                                    trans.rotation = tween.origRotation;
                                    trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, tween.to.x);
                                }else{
                                    trans.rotation = tween.origRotation;
                                }
                            }else{
                                /*trans.rotation = tween.origRotation;
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, val);
                                tween.lastVal = val;*/

                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), tween.axis, move);
                                tween.lastVal = val;

                                //trans.rotation =  * Quaternion.AngleAxis(val, tween.axis);
                            }

                        }else if(tweenAction==TweenAction.ROTATE_AROUND_LOCAL){
                            float move = val -  tween.lastVal;
                            if(isTweenFinished){
                                if(tween.direction>0){
                                    trans.localRotation = tween.origRotation;
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), trans.TransformDirection(tween.axis), tween.to.x);
                                }else{
                                    trans.localRotation = tween.origRotation;
                                }
                            }else{
                                trans.RotateAround((Vector3)trans.TransformPoint( tween.point ), trans.TransformDirection(tween.axis), move);
                                tween.lastVal = val;
                            }
                        }else if(tweenAction==TweenAction.ALPHA){
                            #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2

                            foreach(Material mat in trans.gameObject.renderer.materials){
                                mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                            }

                            #else

                            SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
                            if(ren!=null){
                                ren.color = new Color( ren.color.r, ren.color.g, ren.color.b, val);
                            }else{
                                if(trans.gameObject.renderer!=null){
                                    foreach(Material mat in trans.gameObject.renderer.materials){
                                        mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                                    }
                                }
                                if(trans.childCount>0){
                                    foreach (Transform child in trans) {
                                        if(child.gameObject.renderer!=null){
                                            foreach(Material mat in child.gameObject.renderer.materials){
                                                mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
                                            }
                                        }
                                    }
                                }
                            }

                            #endif
                        }else if(tweenAction==TweenAction.ALPHA_VERTEX){
                            Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
                            Vector3[] vertices = mesh.vertices;
                            Color32[] colors = new Color32[vertices.Length];
                            Color32 c = mesh.colors32[0];
                            c = new Color( c.r, c.g, c.b, val);
                            for (int k= 0; k < vertices.Length; k++) {
                                colors[k] = c;
                            }
                            mesh.colors32 = colors;
                        }else if(tweenAction==TweenAction.COLOR || tweenAction==TweenAction.CALLBACK_COLOR){
                            Color toColor = tweenColor(tween, val);
                            // Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
                            if(tweenAction==TweenAction.COLOR){
                                if(trans.gameObject.renderer!=null){
                                    foreach(Material mat in trans.gameObject.renderer.materials){
                                        mat.color = toColor;
                                    }
                                }
                            }else if(tweenAction==TweenAction.CALLBACK_COLOR){
                                tween.onUpdateColor(toColor);
                            }
                        }

                    }else if(tweenAction>=TweenAction.MOVE){
                        //

                        if(tween.animationCurve!=null){
                            newVect = tweenOnCurveVector(tween, ratioPassed);
                        }else{
                            if(tween.tweenType == LeanTweenType.linear){
                                newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
                            }else if(tween.tweenType >= LeanTweenType.linear){
                                switch(tween.tweenType){
                                    case LeanTweenType.easeOutQuad:
                                        newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuad:
                                        newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuad:
                                        newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
                                    case LeanTweenType.easeInCubic:
                                        newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutCubic:
                                        newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutCubic:
                                        newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuart:
                                        newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutQuart:
                                        newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuart:
                                        newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInQuint:
                                        newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutQuint:
                                        newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutQuint:
                                        newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInSine:
                                        newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutSine:
                                        newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutSine:
                                        newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInExpo:
                                        newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutExpo:
                                        newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutExpo:
                                        newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInCirc:
                                        newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutCirc:
                                        newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutCirc:
                                        newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInBounce:
                                        newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutBounce:
                                        newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutBounce:
                                        newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInBack:
                                        newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutBack:
                                        newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed), easeOutBack(tween.from.y, tween.to.y, ratioPassed), easeOutBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutBack:
                                        newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed), easeInOutBack(tween.from.y, tween.to.y, ratioPassed), easeInOutBack(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInElastic:
                                        newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed), easeInElastic(tween.from.y, tween.to.y, ratioPassed), easeInElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeOutElastic:
                                        newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed), easeOutElastic(tween.from.y, tween.to.y, ratioPassed), easeOutElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.easeInOutElastic:
                                        newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed)); break;
                                    case LeanTweenType.punch:
                                    case LeanTweenType.easeShake:
                                        if(tween.tweenType==LeanTweenType.punch){
                                            tween.animationCurve = LeanTween.punch;
                                        }else if(tween.tweenType==LeanTweenType.easeShake){
                                            tween.animationCurve = LeanTween.shake;
                                        }
                                        tween.to = tween.from + tween.to;
                                        tween.diff = tween.to - tween.from;
                                        if(tweenAction==TweenAction.ROTATE || tweenAction==TweenAction.ROTATE_LOCAL){
                                            tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
                                        }
                                        newVect = tweenOnCurveVector(tween, ratioPassed); break;
                                    case LeanTweenType.easeSpring:
                                        newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed)); break;

                                }
                            }else{
                                newVect = new Vector3( tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
                            }
                        }

                        if(tweenAction==TweenAction.MOVE){
                            trans.position = newVect;
                        }else if(tweenAction==TweenAction.MOVE_LOCAL){
                            trans.localPosition = newVect;
                        }else if(tweenAction==TweenAction.ROTATE){
                            /*if(tween.hasPhysics){
                                trans.gameObject.rigidbody.MoveRotation(Quaternion.Euler( newVect ));
                            }else{*/
                                trans.eulerAngles = newVect;
                            // }
                        }else if(tweenAction==TweenAction.ROTATE_LOCAL){
                            trans.localEulerAngles = newVect;
                        }else if(tweenAction==TweenAction.SCALE){
                            trans.localScale = newVect;
                        }else if(tweenAction==TweenAction.GUI_MOVE){
                            tween.ltRect.rect = new Rect( newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height);
                        }else if(tweenAction==TweenAction.GUI_MOVE_MARGIN){
                            tween.ltRect.margin = new Vector2(newVect.x, newVect.y);
                        }else if(tweenAction==TweenAction.GUI_SCALE){
                            tween.ltRect.rect = new Rect( tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y);
                        }else if(tweenAction==TweenAction.GUI_ALPHA){
                            tween.ltRect.alpha = newVect.x;
                        }else if(tweenAction==TweenAction.GUI_ROTATE){
                            tween.ltRect.rotation = newVect.x;
                        }
                    }
                    //Debug.Log("tween.delay:"+tween.delay + " tween.passed:"+tween.passed + " tweenAction:"+tweenAction + " to:"+newVect+" axis:"+tween.axis);

                    if(tween.onUpdateFloat!=null){
                        tween.onUpdateFloat(val);
                    }else if(tween.onUpdateFloatObject!=null){
                        tween.onUpdateFloatObject(val, tween.onUpdateParam);
                    }else if(tween.onUpdateVector3Object!=null){
                        tween.onUpdateVector3Object(newVect, tween.onUpdateParam);
                    }else if(tween.onUpdateVector3!=null){
                        tween.onUpdateVector3(newVect);
                    }
                    #if !UNITY_METRO
                    else if(tween.optional!=null){ // LeanTween 1.x legacy stuff

                        var onUpdate = tween.optional["onUpdate"];
                        if(onUpdate!=null){
                            Hashtable updateParam = (Hashtable)tween.optional["onUpdateParam"];
                            if((TweenAction)tweenAction==TweenAction.VALUE3){
                                if(onUpdate.GetType() == typeof(string)){
                                    string onUpdateS = onUpdate as string;
                                    customTarget = tween.optional["onUpdateTarget"]!=null ? tween.optional["onUpdateTarget"] as GameObject : trans.gameObject;
                                    customTarget.BroadcastMessage( onUpdateS, newVect );
                                }else if(onUpdate.GetType() == typeof(System.Action<Vector3, Hashtable>)){
                                    System.Action<Vector3, Hashtable> onUpdateA = (System.Action<Vector3, Hashtable>)onUpdate;
                                    onUpdateA(newVect, updateParam);
                                }else{
                                    System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
                                    onUpdateA(newVect);
                                }
                            }else{
                                if(onUpdate.GetType() == typeof(string)){
                                    string onUpdateS = onUpdate as string;
                                    if (tween.optional["onUpdateTarget"]!=null){
                                        customTarget = tween.optional["onUpdateTarget"] as GameObject;
                                        customTarget.BroadcastMessage( onUpdateS, val );
                                    }else{
                                        trans.gameObject.BroadcastMessage( onUpdateS, val );
                                    }
                                }else if(onUpdate.GetType() == typeof(System.Action<float, Hashtable>)){
                                    System.Action<float, Hashtable> onUpdateA = (System.Action<float, Hashtable>)onUpdate;
                                    onUpdateA(val, updateParam);
                                }else if(onUpdate.GetType() == typeof(System.Action<Vector3>)){
                                    System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
                                    onUpdateA( newVect );
                                }else{
                                    System.Action<float> onUpdateA = (System.Action<float>)onUpdate;
                                    onUpdateA(val);
                                }
                            }
                        }
                    }
                    #endif
                }

                if(isTweenFinished){
                    // Debug.Log("finished tween:"+i+" tween:"+tween);
                    if(tweenAction==TweenAction.GUI_ROTATE)
                        tween.ltRect.rotateFinished = true;

                    if(tween.loopType==LeanTweenType.once || tween.loopCount==1){
                        if(tweenAction==TweenAction.DELAYED_SOUND){
                            AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
                        }
                        if(tween.onComplete!=null){
                            removeTween(i);
                            tween.onComplete();

                        }else if(tween.onCompleteObject!=null){
                            removeTween(i);
                            tween.onCompleteObject(tween.onCompleteParam);
                        }

                        #if !UNITY_METRO
                        else if(tween.optional!=null){
                            System.Action callback=null;
                            System.Action<object> callbackWithParam = null;
                            string callbackS=string.Empty;
                            object callbackParam=null;
                            if(tween.optional!=null && tween.trans){
                                if(tween.optional["onComplete"]!=null){
                                    callbackParam = tween.optional["onCompleteParam"];
                                    if(tween.optional["onComplete"].GetType()==typeof(string)){
                                        callbackS = tween.optional["onComplete"] as string;
                                    }else{
                                        if(callbackParam!=null){
                                            callbackWithParam = (System.Action<object>)tween.optional["onComplete"];
                                        }else{
                                            callback = (System.Action)tween.optional["onComplete"];
                                            if(callback==null)
                                                Debug.LogWarning("callback was not converted");
                                        }
                                    }
                                }
                            }
                            removeTween(i);
                            if(callbackWithParam!=null){
                                callbackWithParam( callbackParam );
                            }else if(callback!=null){
                                callback();
                            }else if(callbackS!=string.Empty){
                                if (tween.optional["onCompleteTarget"]!=null){
                                    customTarget = tween.optional["onCompleteTarget"] as GameObject;
                                    if(callbackParam!=null) customTarget.BroadcastMessage ( callbackS, callbackParam );
                                    else customTarget.BroadcastMessage( callbackS );
                                }else{
                                    if(callbackParam!=null) trans.gameObject.BroadcastMessage ( callbackS, callbackParam );
                                    else trans.gameObject.BroadcastMessage( callbackS );
                                }
                            }
                        }
                        #endif
                        else{
                            removeTween(i);
                        }
                    }else{
                        if((tween.loopCount<0 && tween.type==TweenAction.CALLBACK) || tween.onCompleteOnRepeat){
                            if(tweenAction==TweenAction.DELAYED_SOUND){
                                AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
                            }
                            if(tween.onComplete!=null){
                                tween.onComplete();
                            }else if(tween.onCompleteObject!=null){
                                tween.onCompleteObject(tween.onCompleteParam);
                            }
                        }
                        if(tween.loopCount>=1){
                            tween.loopCount--;
                        }
                        if(tween.loopType==LeanTweenType.clamp){
                            tween.passed = Mathf.Epsilon;
                            // tween.delay = 0.0;
                        }else if(tween.loopType==LeanTweenType.pingPong){
                            tween.direction = 0.0f-(tween.direction);
                        }
                    }
                }else if(tween.delay<=0){
                    tween.passed += dt*tween.direction;
                }else{
                    tween.delay -= dt;
                    // Debug.Log("dt:"+dt+" tween:"+i+" tween:"+tween);
                    if(tween.delay<0){
                        tween.passed = 0.0f;//-tween.delay
                        tween.delay = 0.0f;
                    }
                }
            }
        }

        frameRendered = Time.frameCount;
        }
    }
Exemple #36
0
 static public int BroadcastMessage(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             self.BroadcastMessage(a1);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.SendMessageOptions)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             UnityEngine.SendMessageOptions a2;
             a2 = (UnityEngine.SendMessageOptions)LuaDLL.luaL_checkinteger(l, 3);
             self.BroadcastMessage(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(System.Object)))
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             self.BroadcastMessage(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.GameObject self = (UnityEngine.GameObject)checkSelf(l);
             System.String          a1;
             checkType(l, 2, out a1);
             System.Object a2;
             checkType(l, 3, out a2);
             UnityEngine.SendMessageOptions a3;
             a3 = (UnityEngine.SendMessageOptions)LuaDLL.luaL_checkinteger(l, 4);
             self.BroadcastMessage(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function BroadcastMessage to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemple #37
0
        public void Destroy(GameObject go)
        {
            int instanceID;
            ObjectPoolItem item;
            
            if (!CreateObjectPoolItem(go, out instanceID, out item))
            {
                go.transform.SetParent(RecycleBin, false);
                GameObject.Destroy(go);
                return;
            }

            go.BroadcastMessage("OnDespawned", SendMessageOptions.DontRequireReceiver);
            go.transform.SetParent(RecycleBin, false);
            item.GameObjects.Push(go);
        }
	void SelectUnit(GameObject obj)
	{
        shotActionPopup.SetActive(false);
		GameObject newSelectedGo=obj;
		if (newSelectedGo!=selectedGO)
		{
			if (selectedGO!=null)
				selectedGO.BroadcastMessage("DeSelect");
			
			selectedGO=newSelectedGo;
			selectedGO.BroadcastMessage("Select");
		}
	}
        /// <summary>
        /// Applies to a GameObject any custom property found in PropertyCollection
        /// </summary>
        /// <param name="gameObject">GameObject to apply custom properties to</param>
        /// <param name="properties">PropertyCollection to read custom properties from</param>
        public static void ApplyCustomProperties(GameObject gameObject, PropertyCollection properties)
        {
            // nothing to do here...
            if (gameObject == null || properties == null)
                return;

            // Set a layer number for gameObject
            if (properties.HasProperty(Map.Property_Layer))
                gameObject.layer = properties.GetPropertyAsInt(Map.Property_Layer);

            if (properties.HasProperty(Map.Property_LayerName))
                gameObject.layer = LayerMask.NameToLayer(properties.GetPropertyAsString(Map.Property_LayerName));

            // Add a tag for gameObject
            if (properties.HasProperty(Map.Property_Tag))
                gameObject.tag = properties.GetPropertyAsString(Map.Property_Tag);

            int c = 1;
            // Unity 5 Removed AddComponent("string")...
            #if !UNITY_5
            // Add Components for this gameObject
            while (properties.HasProperty(Map.Property_AddComponent + c))
            {
                try
                {
                    gameObject.AddComponent(properties.GetPropertyAsString(Map.Property_AddComponent + c));
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e);
                }
                c++;
            }
            c = 1;
            #endif
            // Can only send messages while playing
            if (Application.isPlaying)
            {
                while (properties.HasProperty(Map.Property_SendMessage + c))
                {
                    string messageToSend = properties.GetPropertyAsString(Map.Property_SendMessage + c);
                    string[] menssage = messageToSend.Split('|');
                    if (menssage.Length == 2)
                    {
                        gameObject.BroadcastMessage(menssage[0], menssage[1], SendMessageOptions.DontRequireReceiver);
                    }
                    if (menssage.Length == 1)
                    {
                        gameObject.BroadcastMessage(menssage[0], SendMessageOptions.DontRequireReceiver);
                    }
                    c++;
                }
            }
            Renderer renderer = gameObject.GetComponent<Renderer>();
            if (renderer != null)
            {
                if (properties.HasProperty(Map.Property_SortingLayerName))
                    renderer.sortingLayerName = properties.GetPropertyAsString(Map.Property_SortingLayerName);

                if (properties.HasProperty(Map.Property_SortingOrder))
                    renderer.sortingOrder = properties.GetPropertyAsInt(Map.Property_SortingOrder);

                if (properties.HasProperty(Map.Property_SetMaterialColor))
                {
                    string[] splitColor = properties.GetPropertyAsString(Map.Property_SetMaterialColor).Split(',');
                    if (splitColor.Length >= 1)
                    {
                        Material mat;
            #if !UNITY_5
                        mat = new Material(Shader.Find("Diffuse"));
            #else
                        mat = new Material(Shader.Find("Standard"));
                        mat.SetFloat("_Mode", 3);
                        mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                        mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        mat.SetInt("_ZWrite", 0);
                        mat.DisableKeyword("_ALPHATEST_ON");
                        mat.EnableKeyword("_ALPHABLEND_ON");
                        mat.DisableKeyword("_ALPHAPREMULTIPLY_ON");
                        mat.renderQueue = 3000;
            #endif
                        mat.SetColor("_Color", new Color32(
                            ((byte)(int.Parse(string.IsNullOrEmpty(splitColor[0]) ? "255" : splitColor[0]))),
                            splitColor.Length >= 2 ? ((byte)(int.Parse(splitColor[1]))) : (byte)255,
                            splitColor.Length >= 3 ? ((byte)(int.Parse(splitColor[2]))) : (byte)255,
                            splitColor.Length >= 4 ? ((byte)(int.Parse(splitColor[3]))) : (byte)255));
                        renderer.material = mat;
                    }
                }
            }
        }
	public static void update()
	{
		if (frameRendered != Time.frameCount)
		{ // make sure update is only called once per frame
			init();

#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5
		dtEstimated = Time.realtimeSinceStartup - previousRealTime;
		if(dtEstimated>0.2f) // a catch put in, when at the start sometimes this number can grow unrealistically large
			dtEstimated = 0.2f;
		previousRealTime = Time.realtimeSinceStartup;
#else
			dtEstimated = Time.unscaledDeltaTime;
#endif

			dtActual = Time.deltaTime;
			maxTweenReached = 0;
			finishedCnt = 0;
			// if(tweenMaxSearch>1500)
			// Debug.Log("tweenMaxSearch:"+tweenMaxSearch +" maxTweens:"+maxTweens);
			for (int i = 0; i <= tweenMaxSearch && i < maxTweens; i++)
			{

				//if(i==0 && tweens[i].toggle)
				//	Debug.Log("tweens["+i+"]"+tweens[i]+" dt:"+dt);
				if (tweens[i].toggle)
				{
					maxTweenReached = i;
					tween = tweens[i];
					trans = tween.trans;
					timeTotal = tween.time;
					tweenAction = tween.type;

					/*if(trans.gameObject.name=="Main Camera"){
						Debug.Log("main tween:"+tween+" i:"+i);
					}*/

					if (tween.useEstimatedTime)
					{
						dt = dtEstimated;
					}
					else if (tween.useFrames)
					{
						dt = 1;
					}
					else if (tween.useManualTime)
					{
						dt = dtManual;
					}
					else if (tween.direction == 0f)
					{
						dt = 0f;
					}
					else
					{
						dt = dtActual;
					}

					if (trans == null)
					{
						removeTween(i);
						continue;
					}
					// Debug.Log("i:"+i+" tween:"+tween+" dt:"+dt);

					// Check for tween finished
					isTweenFinished = false;
					if (tween.delay <= 0)
					{
						if ((tween.passed + dt > tween.time && tween.direction > 0.0f))
						{
							// Debug.Log("i:"+i+" passed:"+tween.passed+" dt:"+dt+" time:"+tween.time+" dir:"+tween.direction);
							isTweenFinished = true;
							tween.passed = tween.time; // Set to the exact end time so that it can finish tween exactly on the end value
						}
						else if (tween.direction < 0.0f && tween.passed - dt < 0.0f)
						{
							isTweenFinished = true;
							tween.passed = Mathf.Epsilon;
						}
					}

					if (!tween.hasInitiliazed && ((tween.passed == 0.0 && tween.delay == 0.0) || tween.passed > 0.0))
					{
						tween.init();
					}

					if (tween.delay <= 0)
					{
						// Move Values
						if (timeTotal <= 0f)
						{
							//Debug.LogError("time total is zero Time.timeScale:"+Time.timeScale+" useEstimatedTime:"+tween.useEstimatedTime);
							ratioPassed = 1f;
						}
						else
						{
							ratioPassed = tween.passed / timeTotal;
						}

						if (ratioPassed > 1.0f)
						{
							ratioPassed = 1.0f;
						}
						else if (ratioPassed < 0f)
						{
							ratioPassed = 0f;
						}
						// Debug.Log("action:"+tweenAction+" ratioPassed:"+ratioPassed + " timeTotal:" + timeTotal + " tween.passed:"+ tween.passed +" dt:"+dt);

						if (tweenAction >= TweenAction.MOVE_X && tweenAction < TweenAction.MOVE)
						{
							if (tween.animationCurve != null)
							{
								val = tweenOnCurve(tween, ratioPassed);
							}
							else
							{
								switch (tween.tweenType)
								{
									case LeanTweenType.linear:
										val = tween.from.x + tween.diff.x * ratioPassed; break;
									case LeanTweenType.easeOutQuad:
										val = easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInQuad:
										val = easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuad:
										val = easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed); break;
									case LeanTweenType.easeInCubic:
										val = easeInCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutCubic:
										val = easeOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutCubic:
										val = easeInOutCubic(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInQuart:
										val = easeInQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutQuart:
										val = easeOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuart:
										val = easeInOutQuart(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInQuint:
										val = easeInQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutQuint:
										val = easeOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutQuint:
										val = easeInOutQuint(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInSine:
										val = easeInSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutSine:
										val = easeOutSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutSine:
										val = easeInOutSine(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInExpo:
										val = easeInExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutExpo:
										val = easeOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutExpo:
										val = easeInOutExpo(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInCirc:
										val = easeInCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutCirc:
										val = easeOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutCirc:
										val = easeInOutCirc(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInBounce:
										val = easeInBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeOutBounce:
										val = easeOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInOutBounce:
										val = easeInOutBounce(tween.from.x, tween.to.x, ratioPassed); break;
									case LeanTweenType.easeInBack:
										val = easeInBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeOutBack:
										val = easeOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeInOutBack:
										val = easeInOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot); break;
									case LeanTweenType.easeInElastic:
										val = easeInElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.easeOutElastic:
										val = easeOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.easeInOutElastic:
										val = easeInOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period); break;
									case LeanTweenType.punch:
									case LeanTweenType.easeShake:
										if (tween.tweenType == LeanTweenType.punch)
										{
											tween.animationCurve = LeanTween.punch;
										}
										else if (tween.tweenType == LeanTweenType.easeShake)
										{
											tween.animationCurve = LeanTween.shake;
										}
										tween.to.x = tween.from.x + tween.to.x;
										tween.diff.x = tween.to.x - tween.from.x;
										val = tweenOnCurve(tween, ratioPassed); break;
									case LeanTweenType.easeSpring:
										val = spring(tween.from.x, tween.to.x, ratioPassed); break;
									default:
										{
											val = tween.from.x + tween.diff.x * ratioPassed; break;
										}
								}

							}

							// Debug.Log("from:"+from+" val:"+val+" ratioPassed:"+ratioPassed);
							if (tweenAction == TweenAction.MOVE_X)
							{
								trans.position = new Vector3(val, trans.position.y, trans.position.z);
							}
							else if (tweenAction == TweenAction.MOVE_Y)
							{
								trans.position = new Vector3(trans.position.x, val, trans.position.z);
							}
							else if (tweenAction == TweenAction.MOVE_Z)
							{
								trans.position = new Vector3(trans.position.x, trans.position.y, val);
							}
							if (tweenAction == TweenAction.MOVE_LOCAL_X)
							{
								trans.localPosition = new Vector3(val, trans.localPosition.y, trans.localPosition.z);
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL_Y)
							{
								trans.localPosition = new Vector3(trans.localPosition.x, val, trans.localPosition.z);
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL_Z)
							{
								trans.localPosition = new Vector3(trans.localPosition.x, trans.localPosition.y, val);
							}
							else if (tweenAction == TweenAction.MOVE_CURVED)
							{
								if (tween.path.orientToPath)
								{
									if (tween.path.orientToPath2d)
									{
										tween.path.place2d(trans, val);
									}
									else
									{
										tween.path.place(trans, val);
									}
								}
								else
								{
									trans.position = tween.path.point(val);
								}
								// Debug.Log("val:"+val+" trans.position:"+trans.position + " 0:"+ tween.curves[0] +" 1:"+tween.curves[1] +" 2:"+tween.curves[2] +" 3:"+tween.curves[3]);
							}
							else if ((TweenAction)tweenAction == TweenAction.MOVE_CURVED_LOCAL)
							{
								if (tween.path.orientToPath)
								{
									if (tween.path.orientToPath2d)
									{
										tween.path.placeLocal2d(trans, val);
									}
									else
									{
										tween.path.placeLocal(trans, val);
									}
								}
								else
								{
									trans.localPosition = tween.path.point(val);
								}
								// Debug.Log("val:"+val+" trans.position:"+trans.position);
							}
							else if (tweenAction == TweenAction.MOVE_SPLINE)
							{
								if (tween.spline.orientToPath)
								{
									if (tween.spline.orientToPath2d)
									{
										tween.spline.place2d(trans, val);
									}
									else
									{
										tween.spline.place(trans, val);
									}
								}
								else
								{
									trans.position = tween.spline.point(val);
								}
							}
							else if (tweenAction == TweenAction.MOVE_SPLINE_LOCAL)
							{
								if (tween.spline.orientToPath)
								{
									if (tween.spline.orientToPath2d)
									{
										tween.spline.placeLocal2d(trans, val);
									}
									else
									{
										tween.spline.placeLocal(trans, val);
									}
								}
								else
								{
									trans.localPosition = tween.spline.point(val);
								}
							}
							else if (tweenAction == TweenAction.SCALE_X)
							{
								trans.localScale = new Vector3(val, trans.localScale.y, trans.localScale.z);
							}
							else if (tweenAction == TweenAction.SCALE_Y)
							{
								trans.localScale = new Vector3(trans.localScale.x, val, trans.localScale.z);
							}
							else if (tweenAction == TweenAction.SCALE_Z)
							{
								trans.localScale = new Vector3(trans.localScale.x, trans.localScale.y, val);
							}
							else if (tweenAction == TweenAction.ROTATE_X)
							{
								trans.eulerAngles = new Vector3(val, trans.eulerAngles.y, trans.eulerAngles.z);
							}
							else if (tweenAction == TweenAction.ROTATE_Y)
							{
								trans.eulerAngles = new Vector3(trans.eulerAngles.x, val, trans.eulerAngles.z);
							}
							else if (tweenAction == TweenAction.ROTATE_Z)
							{
								trans.eulerAngles = new Vector3(trans.eulerAngles.x, trans.eulerAngles.y, val);
							}
							else if (tweenAction == TweenAction.ROTATE_AROUND)
							{
								Vector3 origPos = trans.localPosition;
								Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, tween.axis, -val);
								Vector3 diff = origPos - trans.localPosition;

								trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								trans.rotation = tween.origRotation;

								rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, tween.axis, val);

								//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
								//cubeMarker.transform.position = rotateAroundPt;

							}
							else if (tweenAction == TweenAction.ROTATE_AROUND_LOCAL)
							{
								Vector3 origPos = trans.localPosition;
								trans.RotateAround((Vector3)trans.TransformPoint(tween.point), trans.TransformDirection(tween.axis), -val);
								Vector3 diff = origPos - trans.localPosition;

								trans.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								trans.localRotation = tween.origRotation;
								Vector3 rotateAroundPt = (Vector3)trans.TransformPoint(tween.point);
								trans.RotateAround(rotateAroundPt, trans.TransformDirection(tween.axis), val);

								//GameObject cubeMarker = GameObject.Find("TweenRotatePoint");
								//cubeMarker.transform.position = rotateAroundPt;

							}
							else if (tweenAction == TweenAction.ALPHA)
							{
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2

					    	if(trans.gameObject.renderer){
								foreach(Material mat in trans.gameObject.renderer.materials){
	        						mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
	    						}
							}
							if(trans.childCount>0){
								foreach (Transform child in trans) {
									if(child.gameObject.renderer!=null){
										foreach(Material mat in child.gameObject.renderer.materials){
			        						mat.color = new Color( mat.color.r, mat.color.g, mat.color.b, val);
			    						}
			    					}
								}
							}

#else

								SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();

								if (ren != null)
								{
									ren.color = new Color(ren.color.r, ren.color.g, ren.color.b, val);
								}
								else
								{
									if (trans.gameObject.GetComponent<Renderer>() != null)
									{
										foreach (Material mat in trans.gameObject.GetComponent<Renderer>().materials)
										{
											if (mat.HasProperty("_Color"))
											{
												mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, val);
											}
											else if (mat.HasProperty("_TintColor"))
											{
												Color col = mat.GetColor("_TintColor");
												mat.SetColor("_TintColor", new Color(col.r, col.g, col.b, val));
											}
										}
									}
									if (trans.childCount > 0)
									{
										foreach (Transform child in trans)
										{
											if (child.gameObject.GetComponent<Renderer>() != null)
											{
												foreach (Material mat in child.gameObject.GetComponent<Renderer>().materials)
												{
													mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, val);
												}
											}
										}
									}
								}

#endif
							}
							else if (tweenAction == TweenAction.ALPHA_VERTEX)
							{
								Mesh mesh = trans.GetComponent<MeshFilter>().mesh;
								Vector3[] vertices = mesh.vertices;
								Color32[] colors = new Color32[vertices.Length];
								Color32 c = mesh.colors32[0];
								c = new Color(c.r, c.g, c.b, val);
								for (int k = 0; k < vertices.Length; k++)
								{
									colors[k] = c;
								}
								mesh.colors32 = colors;
							}
							else if (tweenAction == TweenAction.COLOR || tweenAction == TweenAction.CALLBACK_COLOR)
							{
								Color toColor = tweenColor(tween, val);

#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
								SpriteRenderer ren = trans.gameObject.GetComponent<SpriteRenderer>();
								if (ren != null)
								{
									ren.color = toColor;
								}
								else
								{
#endif
									// Debug.Log("val:"+val+" tween:"+tween+" tween.diff:"+tween.diff);
									if (tweenAction == TweenAction.COLOR)
									{
										if (trans.gameObject.GetComponent<Renderer>() != null)
										{
											foreach (Material mat in trans.gameObject.GetComponent<Renderer>().materials)
											{
												mat.color = toColor;
											}
										}
										if (trans.childCount > 0)
										{
											foreach (Transform child in trans)
											{
												if (child.gameObject.GetComponent<Renderer>() != null)
												{
													foreach (Material mat in child.gameObject.GetComponent<Renderer>().materials)
													{
														mat.color = toColor;
													}
												}
											}
										}
									}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2
								}
#endif
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
							}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
							else if (tweenAction == TweenAction.CANVAS_ALPHA)
							{
								Color c = tween.uiImage.color;
								c.a = val;
								tween.uiImage.color = c;
							}
							else if (tweenAction == TweenAction.CANVAS_COLOR)
							{
								Color toColor = tweenColor(tween, val);
								tween.uiImage.color = toColor;
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
							}
							else if (tweenAction == TweenAction.TEXT_ALPHA)
							{
								textAlphaRecursive(trans, val);
							}
							else if (tweenAction == TweenAction.TEXT_COLOR)
							{
								Color toColor = tweenColor(tween, val);
								tween.uiText.color = toColor;
								if (dt != 0f && tween.onUpdateColor != null)
								{
									tween.onUpdateColor(toColor);
								}
								if (trans.childCount > 0)
								{
									foreach (Transform child in trans)
									{
										UnityEngine.UI.Text uiText = child.gameObject.GetComponent<UnityEngine.UI.Text>();
										if (uiText != null)
										{
											uiText.color = toColor;
										}
									}
								}
							}
							else if (tweenAction == TweenAction.CANVAS_ROTATEAROUND)
							{
								// figure out how much the rotation has shifted the object over
								RectTransform rect = tween.rectTransform;
								Vector3 origPos = rect.localPosition;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), tween.axis, -val);
								Vector3 diff = origPos - rect.localPosition;

								rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								rect.rotation = tween.origRotation;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), tween.axis, val);
							}
							else if (tweenAction == TweenAction.CANVAS_ROTATEAROUND_LOCAL)
							{
								// figure out how much the rotation has shifted the object over
								RectTransform rect = tween.rectTransform;
								Vector3 origPos = rect.localPosition;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), rect.TransformDirection(tween.axis), -val);
								Vector3 diff = origPos - rect.localPosition;

								rect.localPosition = origPos - diff; // Subtract the amount the object has been shifted over by the rotate, to get it back to it's orginal position
								rect.rotation = tween.origRotation;
								rect.RotateAround((Vector3)rect.TransformPoint(tween.point), rect.TransformDirection(tween.axis), val);
							}
							else if (tweenAction == TweenAction.CANVAS_PLAYSPRITE)
							{
								int frame = (int)Mathf.Round(val);
								// Debug.Log("frame:"+frame+" val:"+val);
								tween.uiImage.sprite = tween.sprites[frame];
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_X)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(val, current.y, current.z);
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_Y)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(current.x, val, current.z);
							}
							else if (tweenAction == TweenAction.CANVAS_MOVE_Z)
							{
								Vector3 current = tween.rectTransform.anchoredPosition3D;
								tween.rectTransform.anchoredPosition3D = new Vector3(current.x, current.y, val);
							}
#endif

						}
						else if (tweenAction >= TweenAction.MOVE)
						{
							//

							if (tween.animationCurve != null)
							{
								newVect = tweenOnCurveVector(tween, ratioPassed);
							}
							else
							{
								if (tween.tweenType == LeanTweenType.linear)
								{
									newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
								}
								else if (tween.tweenType >= LeanTweenType.linear)
								{
									switch (tween.tweenType)
									{
										case LeanTweenType.easeOutQuad:
											newVect = new Vector3(easeOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInQuad:
											newVect = new Vector3(easeInQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuad:
											newVect = new Vector3(easeInOutQuadOpt(tween.from.x, tween.diff.x, ratioPassed), easeInOutQuadOpt(tween.from.y, tween.diff.y, ratioPassed), easeInOutQuadOpt(tween.from.z, tween.diff.z, ratioPassed)); break;
										case LeanTweenType.easeInCubic:
											newVect = new Vector3(easeInCubic(tween.from.x, tween.to.x, ratioPassed), easeInCubic(tween.from.y, tween.to.y, ratioPassed), easeInCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutCubic:
											newVect = new Vector3(easeOutCubic(tween.from.x, tween.to.x, ratioPassed), easeOutCubic(tween.from.y, tween.to.y, ratioPassed), easeOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutCubic:
											newVect = new Vector3(easeInOutCubic(tween.from.x, tween.to.x, ratioPassed), easeInOutCubic(tween.from.y, tween.to.y, ratioPassed), easeInOutCubic(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInQuart:
											newVect = new Vector3(easeInQuart(tween.from.x, tween.to.x, ratioPassed), easeInQuart(tween.from.y, tween.to.y, ratioPassed), easeInQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutQuart:
											newVect = new Vector3(easeOutQuart(tween.from.x, tween.to.x, ratioPassed), easeOutQuart(tween.from.y, tween.to.y, ratioPassed), easeOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuart:
											newVect = new Vector3(easeInOutQuart(tween.from.x, tween.to.x, ratioPassed), easeInOutQuart(tween.from.y, tween.to.y, ratioPassed), easeInOutQuart(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInQuint:
											newVect = new Vector3(easeInQuint(tween.from.x, tween.to.x, ratioPassed), easeInQuint(tween.from.y, tween.to.y, ratioPassed), easeInQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutQuint:
											newVect = new Vector3(easeOutQuint(tween.from.x, tween.to.x, ratioPassed), easeOutQuint(tween.from.y, tween.to.y, ratioPassed), easeOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutQuint:
											newVect = new Vector3(easeInOutQuint(tween.from.x, tween.to.x, ratioPassed), easeInOutQuint(tween.from.y, tween.to.y, ratioPassed), easeInOutQuint(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInSine:
											newVect = new Vector3(easeInSine(tween.from.x, tween.to.x, ratioPassed), easeInSine(tween.from.y, tween.to.y, ratioPassed), easeInSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutSine:
											newVect = new Vector3(easeOutSine(tween.from.x, tween.to.x, ratioPassed), easeOutSine(tween.from.y, tween.to.y, ratioPassed), easeOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutSine:
											newVect = new Vector3(easeInOutSine(tween.from.x, tween.to.x, ratioPassed), easeInOutSine(tween.from.y, tween.to.y, ratioPassed), easeInOutSine(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInExpo:
											newVect = new Vector3(easeInExpo(tween.from.x, tween.to.x, ratioPassed), easeInExpo(tween.from.y, tween.to.y, ratioPassed), easeInExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutExpo:
											newVect = new Vector3(easeOutExpo(tween.from.x, tween.to.x, ratioPassed), easeOutExpo(tween.from.y, tween.to.y, ratioPassed), easeOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutExpo:
											newVect = new Vector3(easeInOutExpo(tween.from.x, tween.to.x, ratioPassed), easeInOutExpo(tween.from.y, tween.to.y, ratioPassed), easeInOutExpo(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInCirc:
											newVect = new Vector3(easeInCirc(tween.from.x, tween.to.x, ratioPassed), easeInCirc(tween.from.y, tween.to.y, ratioPassed), easeInCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutCirc:
											newVect = new Vector3(easeOutCirc(tween.from.x, tween.to.x, ratioPassed), easeOutCirc(tween.from.y, tween.to.y, ratioPassed), easeOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutCirc:
											newVect = new Vector3(easeInOutCirc(tween.from.x, tween.to.x, ratioPassed), easeInOutCirc(tween.from.y, tween.to.y, ratioPassed), easeInOutCirc(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInBounce:
											newVect = new Vector3(easeInBounce(tween.from.x, tween.to.x, ratioPassed), easeInBounce(tween.from.y, tween.to.y, ratioPassed), easeInBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutBounce:
											newVect = new Vector3(easeOutBounce(tween.from.x, tween.to.x, ratioPassed), easeOutBounce(tween.from.y, tween.to.y, ratioPassed), easeOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInOutBounce:
											newVect = new Vector3(easeInOutBounce(tween.from.x, tween.to.x, ratioPassed), easeInOutBounce(tween.from.y, tween.to.y, ratioPassed), easeInOutBounce(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeInBack:
											newVect = new Vector3(easeInBack(tween.from.x, tween.to.x, ratioPassed), easeInBack(tween.from.y, tween.to.y, ratioPassed), easeInBack(tween.from.z, tween.to.z, ratioPassed)); break;
										case LeanTweenType.easeOutBack:
											newVect = new Vector3(easeOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break;
										case LeanTweenType.easeInOutBack:
											newVect = new Vector3(easeInOutBack(tween.from.x, tween.to.x, ratioPassed, tween.overshoot), easeInOutBack(tween.from.y, tween.to.y, ratioPassed, tween.overshoot), easeInOutBack(tween.from.z, tween.to.z, ratioPassed, tween.overshoot)); break;
										case LeanTweenType.easeInElastic:
											newVect = new Vector3(easeInElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.easeOutElastic:
											newVect = new Vector3(easeOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.easeInOutElastic:
											newVect = new Vector3(easeInOutElastic(tween.from.x, tween.to.x, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.y, tween.to.y, ratioPassed, tween.overshoot, tween.period), easeInOutElastic(tween.from.z, tween.to.z, ratioPassed, tween.overshoot, tween.period)); break;
										case LeanTweenType.punch:
										case LeanTweenType.easeShake:
											if (tween.tweenType == LeanTweenType.punch)
											{
												tween.animationCurve = LeanTween.punch;
											}
											else if (tween.tweenType == LeanTweenType.easeShake)
											{
												tween.animationCurve = LeanTween.shake;
											}
											tween.to = tween.from + tween.to;
											tween.diff = tween.to - tween.from;
											if (tweenAction == TweenAction.ROTATE || tweenAction == TweenAction.ROTATE_LOCAL)
											{
												tween.to = new Vector3(closestRot(tween.from.x, tween.to.x), closestRot(tween.from.y, tween.to.y), closestRot(tween.from.z, tween.to.z));
											}
											newVect = tweenOnCurveVector(tween, ratioPassed); break;
										case LeanTweenType.easeSpring:
											newVect = new Vector3(spring(tween.from.x, tween.to.x, ratioPassed), spring(tween.from.y, tween.to.y, ratioPassed), spring(tween.from.z, tween.to.z, ratioPassed)); break;

									}
								}
								else
								{
									newVect = new Vector3(tween.from.x + tween.diff.x * ratioPassed, tween.from.y + tween.diff.y * ratioPassed, tween.from.z + tween.diff.z * ratioPassed);
								}
							}

							if (tweenAction == TweenAction.MOVE)
							{
								trans.position = newVect;
							}
							else if (tweenAction == TweenAction.MOVE_LOCAL)
							{
								trans.localPosition = newVect;
							}
							else if (tweenAction == TweenAction.ROTATE)
							{
								/*if(tween.hasPhysics){
									trans.gameObject.rigidbody.MoveRotation(Quaternion.Euler( newVect ));
								}else{*/
								trans.eulerAngles = newVect;
								// }
							}
							else if (tweenAction == TweenAction.ROTATE_LOCAL)
							{
								trans.localEulerAngles = newVect;
							}
							else if (tweenAction == TweenAction.SCALE)
							{
								trans.localScale = newVect;
							}
							else if (tweenAction == TweenAction.GUI_MOVE)
							{
								tween.ltRect.rect = new Rect(newVect.x, newVect.y, tween.ltRect.rect.width, tween.ltRect.rect.height);
							}
							else if (tweenAction == TweenAction.GUI_MOVE_MARGIN)
							{
								tween.ltRect.margin = new Vector2(newVect.x, newVect.y);
							}
							else if (tweenAction == TweenAction.GUI_SCALE)
							{
								tween.ltRect.rect = new Rect(tween.ltRect.rect.x, tween.ltRect.rect.y, newVect.x, newVect.y);
							}
							else if (tweenAction == TweenAction.GUI_ALPHA)
							{
								tween.ltRect.alpha = newVect.x;
							}
							else if (tweenAction == TweenAction.GUI_ROTATE)
							{
								tween.ltRect.rotation = newVect.x;
							}
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5
							else if (tweenAction == TweenAction.CANVAS_MOVE)
							{
								tween.rectTransform.anchoredPosition3D = newVect;
							}
							else if (tweenAction == TweenAction.CANVAS_SCALE)
							{
								tween.rectTransform.localScale = newVect;
							}
#endif
						}
						// Debug.Log("tween.delay:"+tween.delay + " tween.passed:"+tween.passed + " tweenAction:"+tweenAction + " to:"+newVect+" axis:"+tween.axis);

						if (dt != 0f && tween.hasUpdateCallback)
						{
							if (tween.onUpdateFloat != null)
							{
								tween.onUpdateFloat(val);
							}
							if (tween.onUpdateFloatRatio != null)
							{
								tween.onUpdateFloatRatio(val, ratioPassed);
							}
							else if (tween.onUpdateFloatObject != null)
							{
								tween.onUpdateFloatObject(val, tween.onUpdateParam);
							}
							else if (tween.onUpdateVector3Object != null)
							{
								tween.onUpdateVector3Object(newVect, tween.onUpdateParam);
							}
							else if (tween.onUpdateVector3 != null)
							{
								tween.onUpdateVector3(newVect);
							}
							else if (tween.onUpdateVector2 != null)
							{
								tween.onUpdateVector2(new Vector2(newVect.x, newVect.y));
							}
						}
#if LEANTWEEN_1
					else if(tween.optional!=null){ // LeanTween 1.x legacy stuff
						var onUpdate = tween.optional["onUpdate"];
						if(onUpdate!=null){
							Hashtable updateParam = (Hashtable)tween.optional["onUpdateParam"];
							if((TweenAction)tweenAction==TweenAction.VALUE3){
								if(onUpdate.GetType() == typeof(string)){
									string onUpdateS = onUpdate as string;
									customTarget = tween.optional["onUpdateTarget"]!=null ? tween.optional["onUpdateTarget"] as GameObject : trans.gameObject;
									customTarget.BroadcastMessage( onUpdateS, newVect );
								}else if(onUpdate.GetType() == typeof(System.Action<Vector3, Hashtable>)){
									System.Action<Vector3, Hashtable> onUpdateA = (System.Action<Vector3, Hashtable>)onUpdate;
									onUpdateA(newVect, updateParam);
								}else{
									System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
									onUpdateA(newVect);
								}
							}else{
								if(onUpdate.GetType() == typeof(string)){
									string onUpdateS = onUpdate as string;
									if (tween.optional["onUpdateTarget"]!=null){
										customTarget = tween.optional["onUpdateTarget"] as GameObject;
										customTarget.BroadcastMessage( onUpdateS, val );
									}else{
										trans.gameObject.BroadcastMessage( onUpdateS, val );
									}
								}else if(onUpdate.GetType() == typeof(System.Action<float, Hashtable>)){
									System.Action<float, Hashtable> onUpdateA = (System.Action<float, Hashtable>)onUpdate;
									onUpdateA(val, updateParam);
								}else if(onUpdate.GetType() == typeof(System.Action<Vector3>)){
									System.Action<Vector3> onUpdateA = (System.Action<Vector3>)onUpdate;
									onUpdateA( newVect );
								}else{
									System.Action<float> onUpdateA = (System.Action<float>)onUpdate;
									onUpdateA(val);
								}
							}
						}
					}
#endif
					}

					if (isTweenFinished)
					{
						if (tween.loopType == LeanTweenType.once || tween.loopCount == 1)
						{
							tweensFinished[finishedCnt] = i;
							finishedCnt++;

							//Debug.Log("finished tween:"+i+" tween:"+tween);
							if (tweenAction == TweenAction.GUI_ROTATE)
								tween.ltRect.rotateFinished = true;

							if (tweenAction == TweenAction.DELAYED_SOUND)
							{
								AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
							}
						}
						else
						{
							if ((tween.loopCount < 0 && tween.type == TweenAction.CALLBACK) || tween.onCompleteOnRepeat)
							{
								if (tweenAction == TweenAction.DELAYED_SOUND)
								{
									AudioSource.PlayClipAtPoint((AudioClip)tween.onCompleteParam, tween.to, tween.from.x);
								}
								if (tween.onComplete != null)
								{
									tween.onComplete();
								}
								else if (tween.onCompleteObject != null)
								{
									tween.onCompleteObject(tween.onCompleteParam);
								}
							}
							if (tween.loopCount >= 1)
							{
								tween.loopCount--;
							}
							// Debug.Log("tween.loopType:"+tween.loopType+" tween.loopCount:"+tween.loopCount+" passed:"+tween.passed);
							if (tween.loopType == LeanTweenType.pingPong)
							{
								tween.direction = 0.0f - (tween.direction);
							}
							else
							{
								tween.passed = Mathf.Epsilon;
							}
						}
					}
					else if (tween.delay <= 0f)
					{
						tween.passed += dt * tween.direction;
					}
					else
					{
						tween.delay -= dt;
						// Debug.Log("dt:"+dt+" tween:"+i+" tween:"+tween);
						if (tween.delay < 0f)
						{
							tween.passed = 0.0f;//-tween.delay
							tween.delay = 0.0f;
						}
					}
				}
			}

			// Debug.Log("maxTweenReached:"+maxTweenReached);
			tweenMaxSearch = maxTweenReached;
			frameRendered = Time.frameCount;

			for (int i = 0; i < finishedCnt; i++)
			{
				j = tweensFinished[i];
				tween = tweens[j];

				// logError("removing tween:"+tween);
				if (tween.onComplete != null)
				{
					System.Action onComplete = tween.onComplete;
					//logError("removing tween for j:"+j+" tween:"+tween);
					removeTween(j);
					//tween.cleanup();
					onComplete();

				}
				else if (tween.onCompleteObject != null)
				{
					System.Action<object> onCompleteObject = tween.onCompleteObject;
					object onCompleteParam = tween.onCompleteParam;
					removeTween(j);
					//tween.cleanup();
					onCompleteObject(onCompleteParam);
				}
#if LEANTWEEN_1
			else if(tween.optional!=null){
				System.Action callback=null;
				System.Action<object> callbackWithParam = null;
				string callbackS=string.Empty;
				object callbackParam=null;
				Hashtable optional = tween.optional;
				if(tween.optional!=null && tween.trans){
					if(tween.optional["onComplete"]!=null){
						callbackParam = tween.optional["onCompleteParam"];
						if(tween.optional["onComplete"].GetType()==typeof(string)){
							callbackS = tween.optional["onComplete"] as string;
						}else{
							if(callbackParam!=null){
								callbackWithParam = (System.Action<object>)tween.optional["onComplete"];
							}else{
								callback = (System.Action)tween.optional["onComplete"];	
								if(callback==null)
									Debug.LogWarning("callback was not converted");
							}
						}
					}
				}
				removeTween(j);
				if(callbackWithParam!=null){
					callbackWithParam( callbackParam );
				}else if(callback!=null){
					callback();
				}else if(callbackS!=string.Empty){
					if (optional["onCompleteTarget"]!=null){
						customTarget = optional["onCompleteTarget"] as GameObject;
						if(callbackParam!=null) customTarget.BroadcastMessage ( callbackS, callbackParam );
						else customTarget.BroadcastMessage( callbackS );
					}else{
						if(callbackParam!=null) trans.gameObject.BroadcastMessage ( callbackS, callbackParam );
						else trans.gameObject.BroadcastMessage( callbackS );
					}
				}
				
			}
#endif
				else
				{
					removeTween(j);
					//tween.cleanup();
				}
			}

		}
	}
Exemple #41
0
    void RaiseEvent(MessageName msg)
    {
        if (interaction == InteractionType.Event)
        {
            if (!useBroadcast)
            {
                switch (msg)
                {
                case MessageName.On_ButtonDown:
                    if (On_ButtonDown != null)
                    {
                        On_ButtonDown(gameObject.name);
                    }
                    break;

                case MessageName.On_ButtonUp:
                    if (On_ButtonUp != null)
                    {
                        On_ButtonUp(gameObject.name);
                    }
                    break;

                case MessageName.On_ButtonPress:

                    if (On_ButtonPress != null)
                    {
                        On_ButtonPress(gameObject.name);
                    }
                    break;
                }
            }
            else
            {
                string method = msg.ToString();

                if (msg == MessageName.On_ButtonDown && downMethodName != "" && useSpecificalMethod)
                {
                    method = downMethodName;
                }

                if (msg == MessageName.On_ButtonPress && pressMethodName != "" && useSpecificalMethod)
                {
                    method = pressMethodName;
                }

                if (msg == MessageName.On_ButtonUp && upMethodName != "" && useSpecificalMethod)
                {
                    method = upMethodName;
                }
                if (receiverGameObject != null)
                {
                    switch (messageMode)
                    {
                    case Broadcast.BroadcastMessage:
                        receiverGameObject.BroadcastMessage(method, name, SendMessageOptions.DontRequireReceiver);
                        break;

                    case Broadcast.SendMessage:
                        receiverGameObject.SendMessage(method, name, SendMessageOptions.DontRequireReceiver);
                        break;

                    case Broadcast.SendMessageUpwards:
                        receiverGameObject.SendMessageUpwards(method, name, SendMessageOptions.DontRequireReceiver);
                        break;
                    }
                }
                else
                {
                    Debug.LogError("Button : " + gameObject.name + " : you must setup receiver gameobject");
                }
            }
        }
    }
 void OnActivateItemEffect(GameObject player)
 {
     player.BroadcastMessage ("OnPlayerGoInvisible", bonusDuration);
 }
Exemple #43
0
	// Use this for initialization
	void Start () 
	{
		UIPanel = GameObject.FindWithTag("ColorFlashScreen");
		player = GameObject.FindWithTag("Player");
		player.BroadcastMessage("AllowRunning", false);
	}