override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {

        if (firstSetting)
        {
            this.IKController = animator.GetComponent<IKControllerHumanoid>();
            this.toKeepDistanceHash = Animator.StringToHash("ToKeepDistance");
            this.rollingHash = Animator.StringToHash("Rolling");
            this.controller = animator.GetComponent<ControllerAIHumanoid>();
            this.firstSetting = false;
        }
        if (!controller.isServer)
            return;

        if (Random.Range(0, 4) == 0)
        {
            animator.SetBool(rollingHash, true);
        }
        IKController.SetDefaultWeaponTarget();
        controller.RVOController.enableRotation = true;
        Vector3 thePointToFleeFrom = controller.CurrentEnemy.transform.position;
        int theGScoreToStopAt = 1000;
        FleePath path = FleePath.Construct(animator.transform.position, thePointToFleeFrom, theGScoreToStopAt);
        path.aimStrength = 10;
        controller.ManuallySetPath(path);
    }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
 {
     var pos = Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer()).transform.position;
     animator.GetComponent<CameraManager>().GetPlayerCamera().transform.position = Vector3.Lerp(	animator.GetComponent<CameraManager>().GetMainCamera().transform.position,
                                                                                                 new Vector3(pos.x + 4, pos.y + 5, pos.z - 15),
                                                                                                 stateInfo.normalizedTime % 1.0f);
 }
Example #3
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (_enemy == null)
     {
         _enemy = animator.GetComponent<Enemy>();
         _nma = animator.GetComponent<NavMeshAgent>();
     }
     _nma.speed = _enemy.moveSpeed;
 }
	// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
	override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 
	{
		animator.GetComponent<GramophoneController>().MusicParticleSystem.Stop();
		AudioSource audioSource = animator.GetComponent<AudioSource>();
		if( audioSource != null )
		{
			audioSource.Stop();
		}
	}
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.GetComponent<Character>().Attack = false;
     if (stateInfo.IsTag("attack")) {
         animator.GetComponent<Character>().MeleeAttack();
     }
     animator.ResetTrigger("attack");
     animator.ResetTrigger("throw");
 }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //myBoxCollider = animator.transform.FindChild("Sword").GetComponent<BoxCollider>();
        myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider;
        myWeaponAttack = animator.GetComponent<PlayerController>().mySwordsAttack;

        myWeaponAttack.damage += 20;
        myBoxCollider.enabled = true;
    }
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (firstSetting)
     {
         this.shootingHash = Animator.StringToHash("Shooting");
         this.IKController = animator.GetComponent<IKControllerHumanoid>();
         this.controller = animator.GetComponent<ControllerAIHumanoid>();
         this.firstSetting = false;
     }
 }
	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
		Attack attack = animator.GetComponent<AttackQueue> ().Attack;
		Enemy enem = animator.GetComponent<Enemy> ();
		Vector3 fromTo = enem.Target.transform.position - animator.transform.position;
		if (fromTo.magnitude <= attack.collSize.magnitude) {
			animator.SetFloat (AnimatorConstants.PUNCH, Random.value);
		} else {
			animator.SetFloat (AnimatorConstants.PUNCH, 0f);
		}
	}
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
    {
        int currentIteration = Mathf.FloorToInt(stateInfo.normalizedTime);
        if (currentIteration != _iteration)
        {
            _iteration = currentIteration;
            if( currentIteration == animator.GetComponent<GameManager>().GetDiceNumber() )
            {
                Debug.Log("iter = " + currentIteration);
                _currentPlayer.GetAnimator().Play("idle");
                animator.GetComponent<CameraManager>().UnfocusOnPlayer(_currentPlayer.GetPlayerColor());
                animator.GetComponent<GameManager>().NextPlayer();
                animator.SetTrigger("PlayerFinishMoveTrigger");
                ok = true; // NANDEEE
                return;
            }
            else
            {
                var nextID = Utils.Instance.GetCaseByID(_currentPlayer.GetCaseID()).GetNextCaseID();
                _currentPlayer.SetCaseID(nextID);
                if (Utils.Instance.GetCaseByID(nextID).GetCaseType() == ECaseType.INTERSECTION)
                    animator.GetComponent<GameManager>().SetDiceNumber(animator.GetComponent<GameManager>().GetDiceNumber() + 1);

                _startMarker = _currentPlayer.transform.position;
                _endMarker = Utils.Instance.GetCaseByID(nextID).GetCasePosition(_currentPlayer.GetPlayerColor(), false);
                float animLength = Vector3.Distance(_startMarker, _endMarker);

                switch (_currentPlayer.GetPlayerColor())
                {
                    case EPlayer.BLUE:
                        PlayerPrefs.SetInt("PLAYER_BLUE_CASEID", nextID);
                        break;
                    case EPlayer.GREEN:
                        PlayerPrefs.SetInt("PLAYER_GREEN_CASEID", nextID);
                        break;
                    case EPlayer.RED:
                        PlayerPrefs.SetInt("PLAYER_RED_CASEID", nextID);
                        break;
                    case EPlayer.YELLOW:
                        PlayerPrefs.SetInt("PLAYER_YELLOW_CASEID", nextID);
                        break;
                }

                animator.SetFloat("MoveInverseDuration", _speed / animLength);
            }
        }
        if(!ok )//TODO : A voir !!
        {
            float fracJourney = stateInfo.normalizedTime % 1.0f;
            _currentPlayer.transform.position = Vector3.Lerp(_startMarker, _endMarker, fracJourney);
            _currentPlayer.transform.LookAt(_endMarker);
        }
    }
Example #10
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (_player == null)
     {
         _player = animator.GetComponent<Player>();
         _nma = animator.GetComponent<NavMeshAgent>();
         _animator = animator;
     }
     _nma.speed = _player.moveSpeed;
     _animator.SetBool("Run", true);
     InputHandler.instance.enabled = true;
 }
Example #11
0
	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		Enemy en = animator.GetComponent<Enemy> ();
		GameObject target = en.Target;
		Vector3 fromTo = target.transform.position - animator.transform.position;
		Vector3 added = fromTo.normalized * en.Speed * Time.deltaTime;
		animator.transform.position += added;

		if (fromTo.magnitude <= animator.GetComponent<AttackQueue> ().Attack.collSize.magnitude / 2) {
			animator.SetBool (AnimatorConstants.TOOCLOSE, true);
		} else {
			animator.SetBool (AnimatorConstants.TOOCLOSE, false);
		}
	}
Example #12
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (firstSetting)
        {
            this.shootingHash = Animator.StringToHash("Shooting");
            this.IKController = animator.GetComponent<IKControllerHumanoid>();
            this.controller = animator.GetComponent<ControllerAIHumanoid>();
            this.firstSetting = false;
        }

        if (!controller.isServer)
            return;
        IKController.SetWeaponTarget(controller.CurrentEnemy.transform);
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //if (AnimationStateEvent == StateEvent.Enter)
        //{
            animator.GetComponent<RomanCharState>().SetState(characterState);
            //Debug.Log("animator script, set: " + characterState);
        //}

            if (animator.GetComponent<RomanCharState>().GetState() == RomanCharState.State.Landing)
            {
                RSUtil.Instance.DelayedAction(() => {
                    animator.SetTrigger("Idle");
                    Debug.Log("FIRED");
                }, 1f);
            }
    }
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     player = animator.GetComponent<Player>();
     stateStartT = Time.time;
     lastIdleTry = stateStartT + 1f;
     lastRand = 100;
 }
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
 {
     if( Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer()).GetAnimPointMiddle() )
     {
         animator.SetTrigger("WheelFreezeTrigger");
     }
 }
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     MobMotion motion = animator.GetComponent<MobMotion>();
     Vector2 movement = motion.PendingMovement;
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
Example #17
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (_player == null)
         _player = animator.GetComponent<Player>();
     animator.SetBool("Died", true);
     InputHandler.instance.enabled = false;
 }
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if(charController == null)
            charController = animator.GetComponent<RomanCharController>();

        //charController.RunStateLogic(AnimState.Enter);
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider;
        myBoxCollider.enabled = false;

        animator.SetBool("Whirlwinding", false);
    }
	public void OpenPanel (Animator anim)
	{

		if (m_Open == anim)
			return;
		
		anim.gameObject.SetActive (true);

		//print (anim.name);
		//phần vá
		if (anim.name == "QuitWindow") {
			anim.GetComponent<Exitgame> ().SetActive ();
		}

		var newPreviouslySelected = EventSystem.current.currentSelectedGameObject;
		
		anim.transform.SetAsLastSibling ();
		
		CloseCurrent ();
		
		m_PreviouslySelected = newPreviouslySelected;
		
		m_Open = anim;
		m_Open.SetBool (m_OpenParameterId, true);
		
		GameObject go = FindFirstEnabledSelectable (anim.gameObject);
		
		SetSelected (go);
	}
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     Vector2 movement = animator.GetComponent<MobMotion>().PendingMovement;
     movement.Normalize();
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
Example #22
0
    // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if(gun == null)
            gun = animator.gameObject.transform.Find("arm_gun:Bip001 R UpperArm/arm_gun:Bip001 R Forearm/arm_gun:Bip001 R Hand/Bazooka1/Spawn"); // todo use full path for faster

        if(bullets == null)
        {
            bullets = new GameObject[maxPool];
            for(int i = 0; i < maxPool; i++)
            {
                bullets[i] = (GameObject)Instantiate(bulletPrefab);
                bullets[i].SetActive(false);
            }
        }

        for(int i = 0; i < numShots; i++)
        {
            //GameObject bullet = Instantiate(bulletPrefab, gun.position, gun.rotation) as GameObject;
            bullets[currentBullet].transform.position = gun.position;
            bullets[currentBullet].transform.rotation = gun.rotation;
            bullets[currentBullet].transform.Rotate(Random.Range(-15f, 15f), Random.Range(-15f, 15f), 0f);
            bullets[currentBullet].GetComponent<Rigidbody>().velocity = gun.TransformDirection(new Vector3(0,0,shootForce));
            bullets[currentBullet].SetActive(true);

            if(++currentBullet >= maxPool)
                currentBullet = 0;
        }

        //currently bug in Unity 5 RC1
        //animator.GetComponent<AudioSource>().PlayOneShot(shootClip);
        animator.GetComponent<AudioSource>().Play();
    }
    //public bool turnedAround;
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!charController)
            charController = animator.GetComponent<SimpleCharController> ();

        //charController.canTurnAround = false;
    }
Example #24
0
	 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
	override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		UnityGuiView view = animator.GetComponent<UnityGuiView>();
		if (view != null)
		{
			//view.OnHidden();
		}
	}
Example #25
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (_enemy == null)
         _enemy = animator.GetComponent<Enemy>();
     animator.SetBool("Died", true);
     _enemy.DropItems();
     _enemy.Invoke("SetActiveFalse", _enemy.hideTime);
 }
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        deathTimer += Time.deltaTime;

        if (deathTimer >= respawnTime) {
            animator.GetComponent<Character>().Death();
        }
    }
Example #27
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (owner == null)
            owner = animator.GetComponent<AIController>();

        target = GameManager.Instance.Wizard.transform;
        owner.agent.SetDestination(target.position);
    }
Example #28
0
	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		Enemy en = animator.GetComponent<Enemy> ();
		GameObject target = en.Target;
		Vector3 fromTo = target.transform.position - animator.transform.position;
		Vector3 added = fromTo.normalized * en.Speed * Time.deltaTime;
		added = _rotation * added;
		animator.transform.position += added;
	}
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 public override void OnStateEnter( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
 {
     ok = false;
     _iteration = -1;
     _currentPlayer = Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer());
     _currentPlayer.ResetAnim();
     _currentPlayer.GetAnimator().Play("running_inPlace");
 }
Example #30
0
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateEnter(animator, stateInfo, layerIndex);

        mn = animator.GetComponent<Minion>();
        mn.MyRgd.constraints = RigidbodyConstraints.None;
        elapsed = 0.0f;
    }