コード例 #1
0
		public override void execute(FSMContext c, object o){
			//UnityEngine.Debug.Log("in hit state");
			A_Fighter fighter;
			fighter = (A_Fighter)o;				
			GameObject gobj = fighter.gobj;
			
			FighterAnimation animation = FighterAnimation.FLINCH_UP;
			
			if (fighter.hurtLocation == Location.HIGH){
				animation = FighterAnimation.FLINCH_UP;
			}
			else if (fighter.hurtLocation == Location.LOW){
				animation = FighterAnimation.FLINCH_DOWN;
			}

			if(fighter.globalActionTimer > 
				(gobj.animation[fighter.animationNameMap[animation]].length / gobj.animation[fighter.animationNameMap[animation]].speed))
			{
				c.dispatch("idle", o);
			}
			
			fighter.globalActionTimer += UnityEngine.Time.deltaTime;
			
			gobj.animation.Play(fighter.animationNameMap[animation]);
				
		}
コード例 #2
0
		public override void execute(FSMContext c, object o)
		{
			A_Fighter 	fighter = (A_Fighter)o;
			A_Attack 	attack 	= fighter.currentAttack;
			
			attack.Execute();
			attack.SpecialExecute();
			
<<<<<<< HEAD
			fighter.currentAttack.SpecialExecute(time);
			if(fighter.takeDamage)
			{
				fighter.Dispatch("takeDamage");			
			}
			
			if(time >= fighter.currentAttack.attackLength)
			{
				//Debug.Log ("attackinginginginging");
				time=0f;
				fighter.currentAttack = new Attack_None(fighter,0,0,0);
				fighter.Dispatch("idle");
			}	
			time+=Time.deltaTime;
=======
			if( attack.CheckComplete() ) { c.dispatch("idle", o); }
			fighter.gobj.animation.CrossFade(attack.AnimationName);
>>>>>>> fd2511965e41334cb3fce993bcedcd531205f267
		}
コード例 #3
0
		public override void execute(FSMContext c, object o){
			A_Fighter fighter;
			fighter = (A_Fighter)o;
			
			fighter.gobj.animation[ fighter.animationNameMap[FighterAnimation.BLOCK] ].wrapMode = UnityEngine.WrapMode.ClampForever;
			fighter.gobj.animation.CrossFade(fighter.animationNameMap[FighterAnimation.BLOCK], 0.03f);
			
			
			// Get knocked back when you are hit
			/*
			if(fighter.gotHit)
			{
				Debug.Log("slide back");
				fighter.gob.transform.Translate(fighter.localForwardVector*-1*fighter.slide* Time.deltaTime);
			}
			*/
			
			if (fighter.currentAction == ActionCommand.NONE){
				c.dispatch("idle", o);
			}
			
			/*
			if(fighter.controllerDirection == "forward" || fighter.controllerDirection == "back")
			{
				fighter.Dispatch("walk");
			}*/
		}
コード例 #4
0
		public override void execute(FSMContext c, object o){
			A_Fighter fighter = (A_Fighter)o;				
			GameObject gobj = fighter.gobj;
			float moveSpeed = fighter.moveSpeed;
			
<<<<<<< HEAD
			A_Fighter fighter;
			fighter = (A_Fighter)o;				
			GameObject gobj = fighter.GetGOB();
			
			//Debug.Log ("fighter "+fighter.playerNumber+" "+"localforwardvector "+fighter.localForwardVector);
			
			
			if(fighter.controllerDirection == "forward" )
			{
				if(!GameManager.CheckCollideAnotherPlayer())
				{
					gobj.transform.Translate(fighter.localForwardVector*fighter.movespeed*Time.deltaTime);	
				}
			}
			else if(fighter.controllerDirection == "back")
			{		
				if(!GameManager.CheckCollideEdge(fighter,fighter.playerNumber))
				gobj.transform.Translate(fighter.localForwardVector*-1*fighter.movespeed*Time.deltaTime);	
			}		
			
			if(fighter.takeDamage)
=======
			if(fighter.currentMovement == MoveCommand.FORWARD || fighter.currentMovement == MoveCommand.FORWARD_UP)
>>>>>>> fd2511965e41334cb3fce993bcedcd531205f267
			{
				if ( GameManager.CheckCanMoveForward(fighter) ){
					gobj.transform.Translate(fighter.localForwardVector * moveSpeed * Time.deltaTime);
				}
				gobj.animation.CrossFade(fighter.animationNameMap[FighterAnimation.WALK_FORWARD]);
			}
			else if(fighter.currentMovement == MoveCommand.BACK || fighter.currentMovement == MoveCommand.BACK_UP)
			{
				if ( GameManager.CheckCanMoveBackward(fighter) ){
					gobj.transform.Translate(fighter.localForwardVector * -1 * moveSpeed * Time.deltaTime);
				}
				gobj.animation.CrossFade(fighter.animationNameMap[FighterAnimation.WALK_BACKWARD]);
			}
			
			
			if( fighter.currentMovement == MoveCommand.NONE)
			{
				c.dispatch("idle", o);
			}
<<<<<<< HEAD
			 
			else if( fighter.controllerDirection != "forward" || fighter.controllerDirection != "back"  )
			{
				fighter.Dispatch("idle");
			}
=======
>>>>>>> fd2511965e41334cb3fce993bcedcd531205f267
		}
コード例 #5
0
ファイル: A_Attack.cs プロジェクト: n8fern/Toy-Hell
        public override void execute(FSMContext fsmc, object o)
        {
            Actor actor = (Actor) o;
            float animationLength = 3.0f;

            if (actor.Animation){
                if (actor.Animation["Attack"]){
                    animationLength = actor.Animation["Attack"].clip.length * (1.0f/actor.AttackSpeed);
                    actor.Animation["Attack"].speed = actor.AttackSpeed;
                    actor.Animation.CrossFade("Attack");
                }
            }

            // Quick Rotation
            actor.controller.transform.LookAt(actor.TargetPosition);
            Debug.DrawLine(actor.Position, actor.TargetPosition);

            // Check to see if the enemy has attacked yet
            if (!actor.HasAttacked && (actor.ActionTimer > actor.AttackTime)){
                if (actor.IsRanged){
                    if (actor.Projectile != null){
                        GameObject attackProjectile = actor.Projectile;
                        GameObject newProjectile = (GameObject)GameObject.Instantiate(attackProjectile, actor.Hitbox.transform.position, Quaternion.identity);

                        // Enemy Shoots Forward
                        //newProjectile.GetComponent<ProjectileScript>().Direction = (actor.TargetPosition - actor.Position).normalized;

                        // Enemy Shoots Toward Player
                        // START
                        newProjectile.transform.LookAt(actor.TargetPlayer.transform.position + new Vector3(0.0f, actor.controller.height/2.0f, 0.0f));
                        newProjectile.GetComponent<ProjectileScript>().Direction = newProjectile.transform.forward;
                        // END

                        newProjectile.GetComponent<ProjectileScript>().Damage = actor.Damage;
                        newProjectile.GetComponent<ProjectileScript>().Speed = actor.ProjectileSpeed;
                        newProjectile.GetComponent<ProjectileScript>().Source = (Enemy)actor;
                        GameObject.Destroy(newProjectile, actor.ProjectileDuration);
                    }
                    actor.HasAttacked = true;
                }
                else{
                    actor.Hitbox.collider.enabled = true;
                    actor.HasAttacked = true;
                }
            }

            if (actor.ActionTimer > (animationLength)){
                actor.Hitbox.collider.enabled = false;
                actor.Hitbox.renderer.enabled = false;
                fsmc.dispatch("idle", o);
            }
            actor.ActionTimer += Time.deltaTime;
        }
コード例 #6
0
ファイル: A_Hurt.cs プロジェクト: n8fern/Toy-Hell
        public override void execute(FSMContext fsmc, object o)
        {
            Actor actor = (Actor) o;
            float animationLength = 3.0f;

            if (actor.Animation){
                if (actor.Animation["Hurt"]){
                    animationLength = actor.Animation["Hurt"].clip.length;
                    actor.Animation.CrossFade("Hurt");
                }
            }

            if (actor.ActionTimer > animationLength){
                fsmc.dispatch("idle", o);
            }
            actor.ActionTimer += Time.deltaTime;
        }
コード例 #7
0
		public override void execute(FSMContext c, object o){
			//UnityEngine.Debug.Log("in hit state");
			A_Fighter fighter;
			fighter = (A_Fighter)o;				
			GameObject gobj = fighter.gobj;
			
			FighterAnimation animation = FighterAnimation.KNOCKDOWN;

			if(fighter.globalActionTimer > 
				(gobj.animation[fighter.animationNameMap[animation]].length / gobj.animation[fighter.animationNameMap[animation]].speed))
			{
				//fighter.isKnockDown = false;
				c.dispatch("idle", o);
			}
			
			fighter.globalActionTimer += UnityEngine.Time.deltaTime;
			gobj.animation.Play(fighter.animationNameMap[animation]);
				
		}
コード例 #8
0
ファイル: A_Jump.cs プロジェクト: n8fern/Toy-Hell
        public override void execute(FSMContext fsmc, object o)
        {
            Actor actor = (Actor) o;
            float animationLength = 3.0f;
            float jumpPower = actor.JumpPower;

            if (actor.Animation){
                if (actor.Animation["Jump"]){
                    animationLength = actor.Animation["Jump"].clip.length;
                    actor.Animation.CrossFade("Jump");
                }
            }

            // Quick Rotation
            actor.controller.transform.LookAt(actor.TargetPosition);
            Debug.DrawLine(actor.Position, actor.TargetPosition);

            Vector3 direction = actor.TargetPosition - actor.Position;

            // Slow Rotation
            if (Quaternion.Angle(actor.Rotation, actor.TargetRotation) > 5.0f){
                actor.Rotation = Quaternion.Slerp(actor.Rotation, actor.TargetRotation, Time.deltaTime *
                    (actor.TurnSpeed));
            }

            Debug.DrawRay(actor.Position, actor.controller.transform.forward);
            /*
            if (direction.magnitude > 0.2f){
                actor.controller.Move(new Vector3((direction.normalized * (actor.MoveSpeed * 0.01f)).x, 0,
                    (direction.normalized * (actor.MoveSpeed * 0.01f)).z));
            }

            if (actor.Animation){
                if (actor.Animation["Attack"]){
                    actor.Animation.CrossFade("Attack");
                }
            }
            */
            if (actor.ActionTimer > animationLength){
                fsmc.dispatch("idle", o);
            }
            actor.ActionTimer += Time.deltaTime;
        }