コード例 #1
0
    public void SetAnim(string animName)
    {
        //  Debug.Log("Anim:" + animName);

        if (m_Anim == null)
        {
            m_Anim = this.transform.Find("model").GetComponent <Animator>();
        }

        //  Debug.Log("m_Anim:" + animName);
        m_Anim.Play(animName);

        switch (animName)
        {
        case "Demo_Run":
            m_StateAnim = StateAnim.Run;
            break;

        case "Demo_Idle":
            m_StateAnim = StateAnim.Idle;
            break;

        case "Demo_Die":
            m_StateAnim = StateAnim.Die;
            break;

        case "Demo_Hit":
            m_StateAnim = StateAnim.Hitted;
            break;

        default:
            m_StateAnim = StateAnim.Attack;
            break;
        }
    }
コード例 #2
0
ファイル: AnimationController.cs プロジェクト: mystik31/nest
    // Update is called once per frame
    void Update()
    {
        Rigidbody2D rb = _motor.GetRigidbody();

        if (_playerController.GetGrounded() && _playerController.GetSpeed() == 1.0)
        {
            _state = StateAnim.RunRight;
        }
        else if (_playerController.GetGrounded() && _playerController.GetSpeed() == -1.0)
        {
            _state = StateAnim.RunLeft;
        }
        else if (!_playerController.GetGrounded() && rb.velocity.y > 0.0)
        {
            _state = StateAnim.Climb;
        }
        else if (!_playerController.GetGrounded() && rb.velocity.y < 0.0)
        {
            _state = StateAnim.Fall;
        }
        else
        {
            _state = StateAnim.Idle;
        }
        Animation();
    }
コード例 #3
0
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.transform.tag == "Human" ||
         hit.transform.tag == "Construct")
     {
         //Debug.Log("Hit");
         CurrAnimation      = StateAnim.Attacking;
         objectBeingDamaged = this.Target;
         Attack();
     }
     else /*if (hit.gameObject.layer == 8)*/ CurrAnimation {
コード例 #4
0
    // Use this for initialization
    public void Start()
    {
        // Get components for pathfinding
        seeker     = GetComponent <Seeker>();
        controller = GetComponent <CharacterController>();

        FastTex   = (Texture2D)Resources.Load("ZombieFastTex");
        SneakyTex = (Texture2D)Resources.Load("ZombieSneakyTex");
        //ToughTex = (Texture2D)Resources.Load ("ZombieToughTex");
        HumanTex = (Texture2D)Resources.Load("HumanTex");
        //MilitaryTex = (Texture2D)Resources.Load ("MilitaryTex");


        CurrUsingAttack = StateCharacterAtkUsing.WeakAttack;

        CurrBehavior = StateCharacterBehave.AtkNearest;

        //CurrCharacterType = StateCharacterType.Human;

        CurrZombType = StateZombieType.Fast;

        CurrAnimation = StateAnim.Standing;

        //isTargeting = false;

        isArmed = false;

        maxHealth = 8;         // was 75;

        currHealth = maxHealth;

        maxResistance = 75;

        currResistance = maxResistance;

        baseAttackDamage = 2;

        timeSinceLastAttack = 0;

        speedPerSec = 2000.0f;


        if (CurrCharacterType == StateCharacterType.Human)
        {
            HumanoidHandler.ListOfHumans.Add(this);
        }
        else
        {
            HumanoidHandler.ListOfZombies.Add(this);
        }
    }
コード例 #5
0
    void TestingFun()
    {
        //isTargeting = true;
        isArmed = false;

        if (CurrCharacterType == StateCharacterType.Zombie)
        {
            CurrAnimation = StateAnim.Walking;
        }
        else
        {
            CurrAnimation = StateAnim.Standing;
        }
    }    // TestingFun()
コード例 #6
0
ファイル: PlayerMovement.cs プロジェクト: Goodos/Platformer
 void Crouch(StateAnim _stateAnim)
 {
     if (_stateAnim == StateAnim.start)
     {
         if (isGrounded)
         {
             anim.Play("Sit");
         }
     }
     if (_stateAnim == StateAnim.back)
     {
         if (isGrounded)
         {
             anim.Play("Idle");
         }
     }
 }
コード例 #7
0
    void Update()
    {
        bool run = player.X == 1 || player.X == -1;

        if(run && playerMotor.Grounded) {
            state = StateAnim.Run;
            Debug.Log("je cours");

        }else if(!run && playerMotor.Grounded){
            state = StateAnim.Idle;
            Debug.Log("je suis static");

        } else if(!playerMotor.Grounded) {
            state = StateAnim.Jump;
            Debug.Log("je saute");
        }
        Animation();
    }
コード例 #8
0
    void Update()
    {
        float x   = Input.GetAxisRaw("Horizontal");
        bool  run = x == 1 || x == -1;

        if (run && player.Grounded)
        {
            state = StateAnim.course;
        }
        else if (!run && player.Grounded)
        {
            state = StateAnim.idle;
        }
        if (!player.Grounded)
        {
            state = StateAnim.jump;
        }
        Animation();
    }
コード例 #9
0
    void Update()
    {
        bool run = player._x == 1 || player._x == -1;

        if (run && motor._Grounded)
        {
            state = StateAnim.Run;
        }

        else if (!run && motor._Grounded)
        {
            state = StateAnim.Idle;
        }

        else if (!motor._Grounded)
        {
            state = StateAnim.Jump;
        }

        Animation();
    }
コード例 #10
0
    void Update()
    {
        bool Walk = player.x == 1 || player.x == -1;

        if (Walk && playerMotor.Grounded)
        {
            state = StateAnim.Walk;
            Debug.Log("Je cours");
        }
        else if (!Walk && playerMotor.Grounded)
        {
            state = StateAnim.Idle;
            Debug.Log("Je ne fais rien");
        }
        else if (!playerMotor.Grounded)
        {
            state = StateAnim.Jump;
            Debug.Log("Je saute");
        }

        Animation();
    }
コード例 #11
0
    }    // AnimateZombie()

    void TranslateAndRotate(float speed)
    {
        if (this.Target != null)
        {
            DirVecToTarget = this.Target.position - transform.position;
        }

        DirVecToTarget.y = 0;
        //Debug.Log (DirVecToTarget.magnitude);
        if (transform.GetComponent <AIPath>().TargetReached || Vector3.Magnitude(DirVecToTarget) < .5f)
        {
            if (this.Target.tag == "Human" || this.Target.tag == "Zombie" || this.Target.tag == "Construct")
            {
                CurrAnimation      = StateAnim.Attacking;
                objectBeingDamaged = this.Target;
                Attack();
            }
            else
            {
                CurrAnimation = StateAnim.Standing;
            }
        }
    }
コード例 #12
0
ファイル: PlayerMovement.cs プロジェクト: Goodos/Platformer
 void Move(StateAnim _stateAnim, Vector3 vector)
 {
     if (_stateAnim == StateAnim.back)
     {
         if (anim.GetCurrentAnimatorStateInfo(0).IsName("Run"))
         {
             anim.Play("Idle");
             return;
         }
     }
     if (_stateAnim == StateAnim.hold)
     {
         Flip(transform, vector);
         playerDirection = vector;
         if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Sit"))
         {
             transform.Translate(vector * runSpeed * Time.deltaTime);
         }
         if (isGrounded && !anim.GetCurrentAnimatorStateInfo(0).IsName("Sit") && !anim.GetCurrentAnimatorStateInfo(0).IsName("Run"))
         {
             anim.Play("Run");
         }
     }
 }
コード例 #13
0
    void AnimateZombie()
    {
        switch( CurrAnimation )
        {
            case StateAnim.Running:
                {//TODO: Check if target moved
                 //  --> get path to new target position (switch to standing)
                 //Check if target reached
                 //  --> switch to Attacking state

                    if( !animation.IsPlaying ("Run") )
                    {
                        animation.Play ("Run");
                    }

                    TranslateAndRotate ( 2 * speedPerSec);// set running speed & move

                    if( TransOfTarget != null
                        && Vector3.Magnitude ( TransOfTarget.position - transform.position ) < 7.50f )
                    {

                        CurrAnimation = StateAnim.Attacking;

                    }

                    break;
                }
            case StateAnim.Walking:
                {//TODO: Check if target moved
                 //  --> get path to new target position (switch to standing)
                 //Check if target reached
                 //  --> switch to Attacking state

                    if( !animation.IsPlaying ("Walk") )
                    {
                        animation.Play ("Walk");
                    }

                    TranslateAndRotate (speedPerSec);// set to walking speed & move

                    if( TransOfTarget != null
                        && Vector3.Magnitude ( TransOfTarget.position - transform.position ) < 7.50f )
                    {
                        CurrAnimation = StateAnim.Attacking;

                    }

                    break;
                }
            case StateAnim.Attacking:
                {//TODO: Check if target moved
                 //  --> get path to new target position (switch to standing)
                 //else attack

                //Debug.Log ("Entered Attacking");
                    HumanoidHandler CurrTarg = null;

                    if( !isArmed )
                    {

                        if( !animation.IsPlaying ("Hit") )
                        {Debug.Log ("Entered Hit");
                            animation.Play ("Hit");
                        }

                        CurrTarg = Attack();
                    }// attack not armed
                    else
                    {

                    }// attack armed

                    if( CurrTarg != null
                        && CurrTarg.currHealth <= 0 )
                    {
                        CurrAnimation = StateAnim.Standing;
                    }

                    break;
                 }
            case StateAnim.Standing: // Character is Standing
            // Standing is where all aquisition of new targets
            // or pathfinding to old, moved targets takes place
                {//TODO: if (hunting)
                 //   find nearest
                 //   if (found)
                 //     -->running/walking
                 // else play()

                    if( CurrBehavior == StateCharacterBehave.AtkNearest
                        && HumanoidHandler.ListOfHumans.Count > 0 )
                    {// find nearest
                        FindTarget ();

                        // TODO: handle get/and wait for path to target
                        seeker.StartPath( transform.position, TransOfTarget.position, SeekerSetPathToTargetCallBack );
                        CurrAnimation = StateAnim.Walking;

                    }
                    else
                    {//Debug.Log ("Play Standing");
                        animation.Play ("Standing");
                        isTargeting = false;
                    }

                    break;
                }
        }// body animation blocks

        //if ( isArmed )
        //{
        //	animation.Play ("HoldGun");
        //}
    }
コード例 #14
0
    // Use this for initialization
    public void Start()
    {
        // Get components for pathfinding
        seeker = GetComponent<Seeker>();
        controller = GetComponent<CharacterController>();

        FastTex = (Texture2D)Resources.Load ("ZombieFastTex");
        SneakyTex = (Texture2D)Resources.Load ("ZombieSneakyTex");
        //ToughTex = (Texture2D)Resources.Load ("ZombieToughTex");
        HumanTex = (Texture2D)Resources.Load ("HumanTex");
        //MilitaryTex = (Texture2D)Resources.Load ("MilitaryTex");

        CurrUsingAttack = StateCharacterAtkUsing.WeakAttack;

        CurrBehavior = StateCharacterBehave.AtkNearest;

        //CurrCharacterType = StateCharacterType.Human;

        CurrZombType = StateZombieType.Fast;

        CurrAnimation = StateAnim.Standing;

        //isTargeting = false;

        isArmed = false;

        maxHealth = 8; // was 75;

        currHealth = maxHealth;

        maxResistance = 75;

        currResistance = maxResistance;

        baseAttackDamage = 2;

        timeSinceLastAttack = 0;

        speedPerSec = 2000.0f;

        if( CurrCharacterType == StateCharacterType.Human )
        {

            HumanoidHandler.ListOfHumans.Add (this);
        }
        else
        {

            HumanoidHandler.ListOfZombies.Add(this);
        }
    }
コード例 #15
0
    // Use this for initialization
    public void Start()
    {
        FastTex     = (Texture2D)Resources.Load("ZombieFastTex");
        SneakyTex   = (Texture2D)Resources.Load("ZombieSneakyTex");
        ToughTex    = (Texture2D)Resources.Load("ZombieToughTex");
        HumanTex    = (Texture2D)Resources.Load("HumanTex");
        MilitaryTex = (Texture2D)Resources.Load("MilitaryTex");


        CurrUsingAttack = StateCharacterAtkUsing.WeakAttack;

        CurrBehavior = StateCharacterBehave.AtkNearest;

        CurrAnimation = StateAnim.Standing;

        isArmed = false;

        maxResistance = 75;

        currResistance = maxResistance;

        maxHealth        = 75;
        baseAttackDamage = 2;
        speedPerSec      = 2.5f;

        timeSinceLastAttack = 0;


        if (CurrCharacterType == StateCharacterType.Human)         // && HumanoidHandler.ListOfHumans.Count == 0 )
        {
            //Debug.Log ("Entered AddHuman");
            transform.tag = "Human";
            //CurrCharacterType = StateCharacterType.Human;
            transform.GetComponentInChildren <SkinnedMeshRenderer>().material.mainTexture = HumanoidHandler.HumanTex;
            myListPos = ListOfHumans.Count;
            HumanoidHandler.ListOfHumans.Add(transform);
        }
        else
        {
            //Debug.Log ("Entered AddZombie");
            transform.tag = "Zombie";
            //CurrCharacterType = StateCharacterType.Zombie;
            switch (CurrZombType)
            {
            case StateZombieType.Fast:             //Just faster speed.
                speedPerSec *= 2;
                maxHealth    = 100;
                //transform.GetComponentInChildren<SkinnedMeshRenderer>().material.mainTexture = HumanoidHandler.FastTex;
                break;

            case StateZombieType.Sneeky:             //Will need to wait until detection is setup!
                //transform.GetComponentInChildren<SkinnedMeshRenderer>().material.mainTexture = HumanoidHandler.SneakyTex;
                break;

            case StateZombieType.Strong:             //Just more damage.
                baseAttackDamage *= 2;
                //transform.GetComponentInChildren<SkinnedMeshRenderer>().material.mainTexture = HumanoidHandler.ToughTex;
                break;
            }


            myListPos = ListOfZombies.Count;
            HumanoidHandler.ListOfZombies.Add(transform);
        }
        emptyTarget = Target;
        currHealth  = maxHealth;

        TestingFun();
    }
コード例 #16
0
    }    // Update()

    void AnimateZombie()
    {
        switch (CurrAnimation)
        {
        case StateAnim.Running:
        {                        //TODO: Check if target moved
                                 //  --> get path to new target position (switch to standing)
                                 //Check if target reached
                                 //  --> switch to Attacking state

            if (!animation.IsPlaying("Run"))
            {
                animation.Play("Run");
            }

            TranslateAndRotate(2 * speedPerSec);                              // set running speed & move

            if (TransOfTarget != null &&
                Vector3.Magnitude(TransOfTarget.position - transform.position) < 7.50f)
            {
                CurrAnimation = StateAnim.Attacking;
            }

            break;
        }

        case StateAnim.Walking:
        {                        //TODO: Check if target moved
                                 //  --> get path to new target position (switch to standing)
                                 //Check if target reached
                                 //  --> switch to Attacking state

            if (!animation.IsPlaying("Walk"))
            {
                animation.Play("Walk");
            }

            TranslateAndRotate(speedPerSec);                             // set to walking speed & move

            if (TransOfTarget != null &&
                Vector3.Magnitude(TransOfTarget.position - transform.position) < 7.50f)
            {
                CurrAnimation = StateAnim.Attacking;
            }

            break;
        }

        case StateAnim.Attacking:
        {                        //TODO: Check if target moved
                                 //  --> get path to new target position (switch to standing)
                                 //else attack

            //Debug.Log ("Entered Attacking");
            HumanoidHandler CurrTarg = null;

            if (!isArmed)
            {
                if (!animation.IsPlaying("Hit"))
                {
                    Debug.Log("Entered Hit");
                    animation.Play("Hit");
                }

                CurrTarg = Attack();
            }                            // attack not armed
            else
            {
            }                            // attack armed

            if (CurrTarg != null &&
                CurrTarg.currHealth <= 0)
            {
                CurrAnimation = StateAnim.Standing;
            }

            break;
        }

        case StateAnim.Standing:                 // Character is Standing
            // Standing is where all aquisition of new targets
            // or pathfinding to old, moved targets takes place
        {                        //TODO: if (hunting)
                                 //   find nearest
                                 //   if (found)
                                 //     -->running/walking
                                 // else play()


            if (CurrBehavior == StateCharacterBehave.AtkNearest &&
                HumanoidHandler.ListOfHumans.Count > 0)
            {                            // find nearest
                FindTarget();

                // TODO: handle get/and wait for path to target
                seeker.StartPath(transform.position, TransOfTarget.position, SeekerSetPathToTargetCallBack);
                CurrAnimation = StateAnim.Walking;
            }
            else
            {                            //Debug.Log ("Play Standing");
                animation.Play("Standing");
                isTargeting = false;
            }

            break;
        }
        }        // body animation blocks



        //if ( isArmed )
        //{
        //	animation.Play ("HoldGun");
        //}
    }    // AnimateZombie()