public override void Initialize()
    {
        //load aim target and look target
        GameObject aimTarget  = (GameObject)GameObject.Instantiate(Resources.Load("IKAimTargetRoot"));
        GameObject lookTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKLookTarget"));

        AimTargetRoot = aimTarget.transform;
        AimTarget     = AimTargetRoot.Find("IKAimTarget").transform;
        LookTarget    = lookTarget.transform;


        LoadCharacterModel(this.CharacterID);



        this.MyEventHandler = GetComponent <CharacterEventHandler>();

        this.Destination = transform.position;
        MyNavAgent       = GetComponent <UnityEngine.AI.NavMeshAgent>();
        UpperBodyState   = MutantUpperBodyStates.Idle;
        ActionState      = HumanActionStates.None;


        this.MyStatus = GetComponent <CharacterStatus>();
        this.MyStatus.ParentCharacter = this;
        //this.MyStatus.Initialize();


        this.MyStatus.RunSpeedModifier = 1f;

        this.Stealth = new CharacterStealth(this);

        this.Inventory      = new CharacterInventory();
        this.CharacterAudio = GetComponent <AudioSource>();

        //each time a human char is initialized it's added to NPC manager's list of human characters to keep track of
        GameManager.Inst.NPCManager.AddMutantCharacter(this);

        CurrentAnimState = new MutantAnimStateIdle(this);
        //SendCommand(CharacterCommands.Unarm);

        this.GoapID = this.MyReference.GoapID;
        MyAI        = GetComponent <AI>();
        MyAI.Initialize(this);

        this.ArmorSystem = new ArmorSystem(this);

        _meleeStrikeStage = 0;
    }
Exemple #2
0
	public void Initialize()
	{
		//load aim target and look target
		GameObject aimTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKAimTargetRoot"));
		GameObject lookTarget = (GameObject)GameObject.Instantiate(Resources.Load("IKLookTarget"));
		AimTargetRoot = aimTarget.transform;
		AimTarget = AimTargetRoot.Find("IKAimTarget").transform;
		LookTarget = lookTarget.transform;


		LoadCharacterModel(this.CharacterID);




		this.MyEventHandler = GetComponent<CharacterEventHandler>();

		this.Destination = transform.position;
		MyNavAgent = GetComponent<NavMeshAgent>();
		UpperBodyState = MutantUpperBodyStates.Idle;
		ActionState = HumanActionStates.None;


		this.MyStatus = new CharacterStatus();
		this.MyStatus.Initialize();

		this.MyStatus.RunSpeedModifier = 1f;

		this.Stealth = new CharacterStealth(this);

		this.Inventory = new CharacterInventory();


		//each time a human char is initialized it's added to NPC manager's list of human characters to keep track of
		GameManager.Inst.NPCManager.AddMutantCharacter(this);

		CurrentAnimState = new MutantAnimStateIdle(this);
		//SendCommand(CharacterCommands.Unarm);

		MyAI = GetComponent<AI>();
		MyAI.Initialize(this);

		this.ArmorSystem = new ArmorSystem(this);

		_meleeStrikeStage = 0;
	
	}
Exemple #3
0
	public override void SendCommand (CharacterCommands command)
	{
		if(command == CharacterCommands.PlayAnimationAction)
		{
			CurrentAnimState = new MutantAnimStateAction(this);
			IsBodyLocked = true;
		}

		if(command == CharacterCommands.AnimationActionDone)
		{
			Debug.Log("Action Done");
			IsBodyLocked = false;
		}





		if(!IsBodyLocked && !IsMoveLocked)
		{
			CurrentAnimState.SendCommand(command);
		}

		if(IsBodyLocked)
		{
			return;
		}

		/*
		if(command == CharacterCommands.IdleAction)
		{
			if(UnityEngine.Random.value > 0.5f)
			{
				this.MyAnimator.SetTrigger("Agonize");
			}
			else
			{
				this.MyAnimator.SetTrigger("Convulse");
			}
		}
		*/

		if(command == CharacterCommands.RunningAttack)
		{
			this.MyAnimator.SetTrigger("RunningAttack");
			MyReference.FixedMeleeRight.GetComponent<MeleeWeapon>().SwingStart();
			ActionState = HumanActionStates.Melee;
		}

		if(command == CharacterCommands.LeftAttack)
		{
			this.MyAnimator.SetTrigger("LeftAttack");
			MyReference.FixedMeleeLeft.GetComponent<MeleeWeapon>().SwingStart();
			ActionState = HumanActionStates.Melee;
		}

		if(command == CharacterCommands.RightAttack)
		{
			this.MyAnimator.SetTrigger("RightAttack");
			MyReference.FixedMeleeRight.GetComponent<MeleeWeapon>().SwingStart();
			ActionState = HumanActionStates.Melee;
		}

		if(command == CharacterCommands.QuickAttack)
		{
			this.MyAnimator.SetTrigger("QuickAttack");
			MyReference.FixedMeleeRight.GetComponent<MeleeWeapon>().SwingStart();
			ActionState = HumanActionStates.Melee;
		}


	}
 // This constructor will create new state taking values from old state
 public MutantAnimStateDeath(MutantAnimStateBase state)
     : this(state.ParentCharacter)
 {
 }
 // This constructor will create new state taking values from old state
 public MutantAnimStateAction(MutantAnimStateBase state)
     : this(state.ParentCharacter)
 {
 }
	// This constructor will create new state taking values from old state
	public MutantAnimStateAction(MutantAnimStateBase state)     
		:this(state.ParentCharacter)
	{

	}
	// This constructor will create new state taking values from old state
	public MutantAnimStateMove(MutantAnimStateBase state)     
		:this(state.ParentCharacter)
	{

	}
    public void OnDeath(Vector3 normal)
    {
        PlayVocal(VocalType.Death);
        MyAI.OnDeath();
        Stealth.OnDeath();
        float posture = UnityEngine.Random.Range(0.1f, 200) / 200f;

        int direction = 1;

        if (normal != Vector3.zero)
        {
            normal = new Vector3(normal.x, 0, normal.z);

            float angleRight   = Vector3.Angle(normal, transform.right);
            float angleForward = Vector3.Angle(normal, transform.forward);


            if (angleRight < 60)
            {
                direction = 3;
            }
            else if (angleRight > 120)
            {
                direction = 2;
            }
            else
            {
                if (UnityEngine.Random.value > 0.5f)
                {
                    direction = 0;
                }
                else
                {
                    direction = 1;
                }
            }
        }

        this.MyAnimator.SetInteger("DeathDirection", direction);
        this.MyAnimator.SetFloat("Blend", posture);
        this.MyAnimator.SetBool("IsDead", true);

        CurrentAnimState = new MutantAnimStateDeath(this);
        IsBodyLocked     = true;
        MyAimIK.solver.SmoothDisable(9);
        MyLeftHandIK.SmoothDisable(12);
        MyHeadIK.SmoothDisable(9);
        MyNavAgent.enabled = false;
        MyReference.LiveCollider.enabled           = false;
        MyReference.DeathCollider.enabled          = true;
        MyReference.DeathCollider.gameObject.layer = 18;

        /*
         * CapsuleCollider collider = GetComponent<CapsuleCollider>();
         * collider.height = 0.5f;
         * collider.radius = 0.6f;
         * collider.center = new Vector3(0, 0, 0);
         * collider.isTrigger = true;
         */

        Unhook();
    }
    public override void SendCommand(CharacterCommands command)
    {
        if (command == CharacterCommands.PlayAnimationAction)
        {
            CurrentAnimState = new MutantAnimStateAction(this);
            IsBodyLocked     = true;
        }

        if (command == CharacterCommands.AnimationActionDone)
        {
            //Debug.Log("Action Done");
            IsBodyLocked = false;
        }



        if (!IsBodyLocked && !IsMoveLocked)
        {
            CurrentAnimState.SendCommand(command);
        }

        if (IsBodyLocked)
        {
            return;
        }

        /*
         * if(command == CharacterCommands.IdleAction)
         * {
         *      if(UnityEngine.Random.value > 0.5f)
         *      {
         *              this.MyAnimator.SetTrigger("Agonize");
         *      }
         *      else
         *      {
         *              this.MyAnimator.SetTrigger("Convulse");
         *      }
         * }
         */

        if (command == CharacterCommands.RunningAttack)
        {
            this.MyAnimator.SetTrigger("RunningAttack");
            _meleeSide  = 1;
            ActionState = HumanActionStates.Melee;
        }

        if (command == CharacterCommands.LeftAttack)
        {
            this.MyAnimator.SetTrigger("LeftAttack");
            _meleeSide  = 0;
            ActionState = HumanActionStates.Melee;
        }

        if (command == CharacterCommands.RightAttack)
        {
            this.MyAnimator.SetTrigger("RightAttack");
            _meleeSide  = 1;
            ActionState = HumanActionStates.Melee;
        }

        if (command == CharacterCommands.QuickAttack)
        {
            this.MyAnimator.SetTrigger("QuickAttack");
            _meleeSide  = 1;
            ActionState = HumanActionStates.Melee;
        }

        if (command == CharacterCommands.Bite)
        {
            if (ActionState != HumanActionStates.None || MyAI.BlackBoard.TargetEnemy == null)
            {
                return;
            }



            //Debug.Log("Start biting");
            Vector3 lineOfSight = MyAI.BlackBoard.TargetEnemy.transform.position - transform.position;


            //stop movement
            SendCommand(CharacterCommands.Idle);
            IsBodyLocked       = true;
            MyNavAgent.enabled = false;

            //place my position right behind target
            transform.position = MyAI.BlackBoard.TargetEnemy.transform.position - lineOfSight.normalized * 1f;

            //align my facing direction to enemy's
            lineOfSight = new Vector3(lineOfSight.x, 0, lineOfSight.z);
            Quaternion rotation = Quaternion.LookRotation(lineOfSight);
            transform.rotation = rotation;

            MyAnimator.SetTrigger("Bite");
            _strangleTarget = MyAI.BlackBoard.TargetEnemy;


            ActionState = HumanActionStates.Strangle;
        }
    }