コード例 #1
0
    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);
 }
コード例 #3
0
ファイル: EnemyChasing.cs プロジェクト: Lobo-Prix/TeraTale
 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;
 }
コード例 #4
0
	// 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();
		}
	}
コード例 #5
0
 // 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;
    }
コード例 #7
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;
     }
 }
コード例 #8
0
	// 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);
        }
    }
コード例 #10
0
ファイル: PlayerRunning.cs プロジェクト: Lobo-Prix/TeraTale
 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;
 }
コード例 #11
0
ファイル: MoveTowards.cs プロジェクト: kunodev/GGJ2016
	// 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);
		}
	}
コード例 #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);
    }
コード例 #13
0
    // 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);
    }
 // 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");
     }
 }
コード例 #15
0
	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);
	}
コード例 #16
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     player = animator.GetComponent<Player>();
     stateStartT = Time.time;
     lastIdleTry = stateStartT + 1f;
     lastRand = 100;
 }
コード例 #17
0
    // 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);
            }
    }
コード例 #18
0
    //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;
    }
コード例 #19
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();
		}
	}
コード例 #20
0
ファイル: firepooling.cs プロジェクト: ezink/Unity-Workshop
    // 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();
    }
コード例 #21
0
 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);
 }
    // 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);
    }
コード例 #23
0
ファイル: PlayerDying.cs プロジェクト: Lobo-Prix/TeraTale
 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;
 }
コード例 #24
0
 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);
 }
コード例 #25
0
ファイル: OrthoMove.cs プロジェクト: kunodev/GGJ2016
	// 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;
	}
コード例 #26
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);
    }
コード例 #27
0
    // 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();
        }
    }
 // 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");
 }
コード例 #29
0
ファイル: EnemyDying.cs プロジェクト: Lobo-Prix/TeraTale
 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);
 }
コード例 #30
0
ファイル: Flail.cs プロジェクト: heyx3/Warmage
    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;
    }
コード例 #31
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)
 {
     m_foir = animator.GetComponent <FindObjectsInRadius>();
 }
コード例 #32
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)
 {
     boss             = animator.GetComponent <bossController>();
     atkNum           = animator.GetInteger("attackNum");
     boss.isAttacking = true;
 }
コード例 #33
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)
    //{
    //}

    // 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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Character car = animator.GetComponent <Character>();

        car.SwapToMain();
    }
コード例 #34
0
    //bool anim_finished = false;

    // Start is called before the first frame update
    void Start()
    {
        anim.GetComponent <Animator>();
    }
コード例 #35
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)
 {
     pc           = animator.GetComponent <PlayerController>();
     pc.moveSpeed = moveSpeed;
 }
コード例 #36
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)
 {
     player = animator.GetComponent <PlayerBase>();
     player.PMovement.SetMovementEnabled(false);
 }
コード例 #37
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     _brain  = animator.GetComponent <EnemyBrainController>();
     _combat = animator.GetComponent <EnemyCombatController>();
     _agent  = animator.GetComponent <NavMeshAgent>();
 }
コード例 #38
0
ファイル: Attacking.cs プロジェクト: gd55dawson/Unity3Final
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     _AI = animator.GetComponent <AI>();
 }
コード例 #39
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) {
    //
    //}

    // 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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.GetComponent <Player>().ResetAbilities();
    }
コード例 #40
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)
    {
        if (GlobalControl.isPaused)
        {
            return;
        }
        animator.SetInteger("RedEnemyCurrentState", animator.GetComponent <RedEnemyAI>().STATE_WALK);
        if (animator.GetComponent <RedEnemyAI>().transform.localScale.x > 0)
        {
            float forceX = 0f;

            if (animator.GetComponent <RedEnemyAI>().redEnemyBody.velocity.x < animator.GetComponent <RedEnemyAI>().maxVelocity)
            {
                if (animator.GetComponent <RedEnemyAI>().grounded)
                {
                    forceX = animator.GetComponent <RedEnemyAI>().moveForce;
                }
                else
                {
                    forceX = animator.GetComponent <RedEnemyAI>().moveForce * 0.5f;
                }
            }
            animator.GetComponent <RedEnemyAI>().redEnemyBody.AddForce(new Vector2(forceX, 0));
        }
        else
        {
            float forceX = 0f;

            if (animator.GetComponent <RedEnemyAI>().redEnemyBody.velocity.x > -animator.GetComponent <RedEnemyAI>().maxVelocity)
            {
                if (animator.GetComponent <RedEnemyAI>().grounded)
                {
                    forceX = -animator.GetComponent <RedEnemyAI>().moveForce;
                }
                else
                {
                    forceX = -animator.GetComponent <RedEnemyAI>().moveForce * 0.5f;
                }
            }
            animator.GetComponent <RedEnemyAI>().redEnemyBody.AddForce(new Vector2(forceX, 0));
        }
    }
コード例 #41
0
ファイル: StateAvatarStandby.cs プロジェクト: slb1988/agame
        public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            BaseMonoAvatar component = animator.GetComponent <BaseMonoAvatar>();

            animator.SetFloat("IdleCD", component.config.StateMachinePattern.IdleCD);
        }
コード例 #42
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)
 {
     animator.GetComponent <Player>().Jump = true;
 }
コード例 #43
0
 // Use this for initialization
 void Start()
 {
     vbBtnObj = GameObject.Find("selectSphere");
     vbBtnObj.GetComponent <VirtualButtonBehaviour>().RegisterEventHandler(this);
     cubeAni.GetComponent <Animator>();
 }
コード例 #44
0
ファイル: Bot.cs プロジェクト: jimc1664/Crystal-Caves
    public override void Update()
    {
        float lAt = AttackTimer;

        AttackTimer -= Time.deltaTime;
        RunTimer    -= Time.deltaTime;
        if (RunTimer < 0)
        {
            RunTimer = 0;
        }


        float maxA = 3;

        if (Awareness > maxA)
        {
            Awareness = maxA;
        }


        if (Player != null)
        {
            if (XZSqrMagnitude(Player.position, Bdy.position) < 15 + Awareness * 15)
            {
                Awareness   += Time.deltaTime * 1.5f;
                HearPosAcum += Player.position + Player.velocity * 0.75f;
                HearMod++;
            }
        }

        Awareness -= Time.deltaTime;

        if (HearMod > 0)
        {
            HearPos     = HearPosAcum / HearMod;
            HearPosAcum = Vector3.zero;
            HearMod     = 0;
        }
        // State = Awareness > 0.5f ? BotState.Investigate : BotState.Wander;
        TargetTime -= Time.deltaTime;


        switch (State)
        {
        case BotState.Wander:
            if (Awareness > 0.5f)
            {
                State  = BotState.Investigate;
                Target = null;
            }
            else if (Awareness < 0)
            {
                Awareness = 0;
            }

            speed = WanderSpeed * (1 - Awareness);
            if (Target == null)
            {
                //Target = FindObjectOfType<UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().transform;

                if (TargetTime < -1)
                {
                    if (Player == null)
                    {
                        var fps = FindObjectOfType <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>();
                        if (fps)
                        {
                            Player = fps.GetComponent <Rigidbody>();
                        }
                    }

                    if (Random.value > 0.65f && Player != null)
                    {
                        Target = Player.transform;
                        //  Seek.StartPath(transform.position, Target.position);
                        TargetTime = Random.Range(5, 9) * 2;
                    }
                    else
                    {
                        Target = Points.GetChild(Random.Range(0, Points.childCount));
                        //  Seek.StartPath(transform.position, Target.position);
                        TargetTime = Random.Range(6, 18) * 20;
                    }
                }
            }

            if (Target != null)
            {
                TargetPos = Target.position;
                if (XZSqrMagnitude(TargetPos, Bdy.position) < endReachedDistance * endReachedDistance ||
                    (TargetTime) < 0)
                {
                    Target     = null;
                    TargetTime = Random.Range(-0.8f, 0);
                }
            }
            break;

        case BotState.Investigate:
            speed = InvestigateSpeed;

            if (Player != null && XZSqrMagnitude(Player.position, Bdy.position) < 10 + Awareness * 15 && RunTimer < 10)
            {
                speed    *= 1.8f;
                RunTimer += Time.deltaTime * 3;
            }
            TargetPos = HearPos;
            if (Player == null)
            {
                var fps = FindObjectOfType <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>();
                if (fps)
                {
                    Player = GetComponent <Rigidbody>();
                }
            }
            else
            {
                if (XZSqrMagnitude(Player.position, Bdy.position) < 11)
                {
                    ///die
                    if (AttackTimer < 0)
                    {
                        Anim.SetTrigger("Attack");
                        var audio = Anim.GetComponent <AudioSource>();
                        audio.pitch *= Random.Range(0.8f, 1.2f);
                        audio.Play();
                        AttackTimer = 3;
                        DoDamage    = true;
                    }
                }
            }

            if (AttackTimer > 0)
            {
                if (AttackTimer > 1.5)
                {
                    speed = InvestigateSpeed * 2.5f;
                }
                else if (AttackTimer > 0.7)
                {
                    speed = InvestigateSpeed * 0.5f;
                }

                if (AttackTimer < 2.3f)
                {
                    if (AttackTimer > 1)
                    {
                        if (DoDamage && Player != null && XZSqrMagnitude(Player.position, Bdy.position) < 15)
                        {
                            DoDamage = false;
                            var wg = Player.GetComponentInChildren <WaveGen>();
                            if (wg)
                            {
                                wg.Hp -= 22;
                            }
                        }
                    }
                    else
                    {
                        DoDamage = false;
                    }
                }
            }
            else if (Awareness < -2.5f || (Awareness < 0 && XZSqrMagnitude(TargetPos, Bdy.position) < endReachedDistance * endReachedDistance))
            {
                State      = BotState.Wander;
                Awareness  = 0;
                TargetTime = Random.Range(-0.8f, -0.3f);
            }
            break;
        }

        var v = Bdy.velocity; v.y = 0;

        Anim.SetFloat("Speed", v.magnitude / InvestigateSpeed);
    }
コード例 #45
0
ファイル: ShootState.cs プロジェクト: melekkoc/3DTankGame
    // 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 ani, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ani.GetComponent <EnemyAI>().SetLoookRotation();
        ani.gameObject.GetComponent <EnemyAI>().Shoot();
    }
コード例 #46
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)
 {
     animator.GetComponent <BoxCollider2D>().enabled = true;
 }
コード例 #47
0
ファイル: StorkAttack.cs プロジェクト: rennieb1/HighwynnGame
 void Start()
 {
     storkBoss = anim.GetComponent <StorkBossMainScript>();
 }
コード例 #48
0
 void Start()
 {
     AnimatorClipInfo[] animatorInfo = popupFadeAnimator.GetCurrentAnimatorClipInfo(0);
     Destroy(gameObject, animatorInfo [0].clip.length - 0.05f);
     mPopupText = popupFadeAnimator.GetComponent <Text> ();
 }
コード例 #49
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     characterController = animator.GetComponent <CharacterController>();
 }
コード例 #50
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)
 {
     animator.GetComponent <NavMeshAgent>().speed = 0;
     animator.GetComponent <EnemyManager>().LookAtTarget();
 }
コード例 #51
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)
 {
     playerPos  = animator.GetComponent <Enemy>().playerPos;
     projectile = animator.GetComponent <Enemy>().enemyTemplate.projectileOrSummon;
     pooler     = ObjectPooler.instance;
 }
コード例 #52
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     wizz = animator.GetComponent <Wizard> ();
     animator.SetBool("Walking", false);
     wizz.Attacking = true;
 }
コード例 #53
0
 void OnEnable()
 {
     AnimatorClipInfo[] clipInfo = animator.GetCurrentAnimatorClipInfo(0);
     Destroy(gameObject, clipInfo[0].clip.length);
     damageTex = animator.GetComponent <Text>();
 }
コード例 #54
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (GlobalControl.isPaused)
        {
            return;
        }
        if (animator.GetComponent <YellowEnemyAI>().transform.localScale.x > 0)
        {
            float forceX = 0f;

            if (animator.GetComponent <YellowEnemyAI>().YellowEnemyBody.velocity.x < animator.GetComponent <YellowEnemyAI>().maxVelocity)
            {
                if (animator.GetComponent <YellowEnemyAI>().grounded)
                {
                    forceX = animator.GetComponent <YellowEnemyAI>().moveForce;
                }
                else
                {
                    forceX = animator.GetComponent <YellowEnemyAI>().moveForce * 0.5f;
                }
            }
            animator.GetComponent <YellowEnemyAI>().YellowEnemyBody.AddForce(new Vector2(forceX, 0));
        }
        else
        {
            float forceX = 0f;

            if (animator.GetComponent <YellowEnemyAI>().YellowEnemyBody.velocity.x > -animator.GetComponent <YellowEnemyAI>().maxVelocity)
            {
                if (animator.GetComponent <YellowEnemyAI>().grounded)
                {
                    forceX = -animator.GetComponent <YellowEnemyAI>().moveForce;
                }
                else
                {
                    forceX = -animator.GetComponent <YellowEnemyAI>().moveForce * 0.5f;
                }
            }
            animator.GetComponent <YellowEnemyAI>().YellowEnemyBody.AddForce(new Vector2(forceX, 0));
        }
    }
コード例 #55
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)
 {
     animator.GetComponent <PlayerController>().canMove = false;
 }
コード例 #56
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)
    {
        animator.GetComponent <Character>().TakingDamage = true;

        //animator.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
    }
コード例 #57
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.GetComponent <BaseMonoAvatar>().RunBSStart();
 }
コード例 #58
0
ファイル: SNGun.cs プロジェクト: Niezoor/ScriptsDemo
    public void SetDirection(Vector2 dir)
    {
        if (aiming && animator)
        {
            if (owner.movementController.armsAnimationController)
            {
                float angle = SNMovementController.Angle(dir);

                direction = dir;

                /*if (animator != null) {
                 * animator.SetFloat ("Horizontal", dir.x);
                 * animator.SetFloat ("Vertical", dir.y);
                 * }*/
                //Debug.Log ("angle " + angle);
                //angle = -(angle - 90);
                Quaternion     newRot   = Quaternion.Euler(0, 0, -(angle - 90));
                SpriteRenderer rendrer  = animator.GetComponent <SpriteRenderer> ();
                SpriteRenderer rendrer2 = rendrer;

                //Debug.Log ("angle2 " + angle);

                rendrer2 = owner.movementController.armsAnimationController.GetComponent <SpriteRenderer> ();
                owner.movementController.armsAnimationController.transform.parent.localRotation = newRot;
                if (angle >= 45 && angle < 135)
                {
                    //right
                    horizontal                 = true;
                    rendrer.flipY              = false;
                    rendrer2.flipY             = false;
                    gunTransform.localPosition = owner.movementController.gunPositionR;
                }
                else if (angle >= 135 && angle < 225)
                {
                    //down
                    horizontal                 = false;
                    rendrer.flipY              = false;
                    rendrer2.flipY             = false;
                    gunTransform.localPosition = owner.movementController.gunPositionD;
                }
                else if (angle >= 225 && angle < 315)
                {
                    //left
                    horizontal                 = true;
                    rendrer.flipY              = true;
                    rendrer2.flipY             = true;
                    gunTransform.localPosition = owner.movementController.gunPositionL;
                }
                else if (angle >= 315)
                {
                    //up
                    horizontal                 = false;
                    rendrer.flipY              = false;
                    rendrer2.flipY             = false;
                    gunTransform.localPosition = owner.movementController.gunPositionU;
                }
                else                     //&& angle < 45)
                                         //up
                {
                    horizontal                 = false;
                    rendrer.flipY              = false;
                    rendrer2.flipY             = false;
                    gunTransform.localPosition = owner.movementController.gunPositionU;
                }
                //transform.localRotation = newRot;


                owner.movementController.armsAnimationController.Play("Aim" + GetAnimationMode());
                //SNWeapon.SetAnimationDirection (owner.movementController.animationController, dir);
                //animator.Play ("Hold" + GetAnimationMode ());
                if (!shotProceed)
                {
                    PlayAnimation("Hold" + GetAnimationMode());
                }
            }
        }
    }
コード例 #59
0
    public IEnumerator ShowPopup_IEnumerator()
    {
        SoundManager.instance.SFX_GameOver();
        bg.gameObject.SetActive(false);
        btnReplay.gameObject.SetActive(false);
        btnSkip.gameObject.SetActive(false);
        btnFreeCoin.gameObject.SetActive(false);
        btnChest.gameObject.SetActive(false);
        btnDailyReward.gameObject.SetActive(false);
        btnFreeHeart.gameObject.SetActive(false);
        btnShopCoin.gameObject.SetActive(false);
        btnShopSkin.gameObject.SetActive(false);
        ballAnimator.gameObject.SetActive(false);
        txtLevel.gameObject.SetActive(false);
        txtFailed.gameObject.SetActive(false);
        btnNextBallPreview.gameObject.SetActive(false);
        btnBackBallPreview.gameObject.SetActive(false);
        btnTryBallPreview.gameObject.SetActive(false);
        btnActiveBallPreview.gameObject.SetActive(false);
        btnShop.gameObject.SetActive(false);
        btnShopHeart.gameObject.SetActive(false);

        yield return(new WaitForSeconds(0.1f));

        bg.gameObject.SetActive(true);
        bg.ShowView();

        yield return(new WaitForSeconds(0.2f));

        txtLevel.gameObject.SetActive(true);
        txtLevel.gameObject.GetComponent <BBUIView>().ShowView();
        txtFailed.gameObject.SetActive(true);
        txtFailed.gameObject.GetComponent <BBUIView>().ShowView();

        yield return(new WaitForSeconds(0.5f));

        btnFreeCoin.gameObject.SetActive(true);
        btnFreeCoin.GetComponent <BBUIView>().ShowView();
        if (Config.CheckShowStartPack())
        {
            btnChest.gameObject.SetActive(true);
            btnChest.GetComponent <BBUIView>().ShowView();
        }
        btnFreeHeart.gameObject.SetActive(true);
        btnFreeHeart.GetComponent <BBUIView>().ShowView();
        btnShopSkin.gameObject.SetActive(true);
        btnShopSkin.GetComponent <BBUIView>().ShowView();

        btnShopCoin.gameObject.SetActive(true);
        btnShopCoin.GetComponent <BBUIView>().ShowView();
        btnShopHeart.gameObject.SetActive(true);
        btnShopHeart.GetComponent <BBUIView>().ShowView();

        yield return(new WaitForSeconds(0.2f));

        btnShop.gameObject.SetActive(true);
        btnShop.GetComponent <BBUIView>().ShowView();


        yield return(new WaitForSeconds(0.2f));

        ballAnimator.gameObject.SetActive(true);
        ballAnimator.GetComponent <BBUIView>().ShowView();
        btnDailyReward.gameObject.SetActive(true);
        btnDailyReward.GetComponent <BBUIView>().ShowView();

        btnNextBallPreview.gameObject.SetActive(true);
        btnNextBallPreview.GetComponent <BBUIView>().ShowView();

        btnBackBallPreview.gameObject.SetActive(true);
        btnBackBallPreview.GetComponent <BBUIView>().ShowView();

        yield return(new WaitForSeconds(0.5f));

        btnSkip.gameObject.SetActive(true);
        btnSkip.GetComponent <BBUIView>().ShowView();

        yield return(new WaitForSeconds(1f));

        lockPopup.SetActive(false);

        yield return(new WaitForSeconds(3f));

        btnReplay.gameObject.SetActive(true);
        btnReplay.GetComponent <BBUIView>().ShowView();

        if (Config.currIDBallRescue != -1)
        {
            rescuePopup.OpenRescuePopup();
        }
        else if (Config.CheckDailyReward())
        {
            //  dailyRewardPopup.OpenPopup();
        }
    }
コード例 #60
0
    // 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
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.GetComponent <Character>().TakingDamage = false;
    }