// 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)
    {
        roomba          = animator.GetComponent <RoombaBehaviour> ();
        hd              = animator.GetComponent <HurtAndDamage> ();
        hd.canHurtOther = true;
        // decide where to shoot the roomba at
        targetPos = roomba.targetLastPos;
        // guess where the player might be at after fade seconds
//		if(roomba.target){
//			Rigidbody2D rb = roomba.target.GetComponent<Rigidbody2D> ();
//			if(rb){
//				targetPos = shootPos + (Vector3)(rb.velocity * fadeSeconds);
//			}
//		}
        Vector3 targetDir = animator.transform.up;

        if (roomba.cs.controller == Controller.Boss)
        {
            targetDir = (targetPos - animator.transform.position).normalized;
        }
        else if (roomba.cs.controller == Controller.Hacker)
        {
            targetDir = roomba.incomingVelocity.normalized;
            Debug.Log(targetDir);
        }

        roomba.body.velocity = targetDir * roomba.thrust;

        animator.SetFloat("velocity", roomba.body.velocity.magnitude);

        // enable collision check for explosion
        roomba.checkCollision = true;
        // reset distToTarget
        animator.SetFloat("distToTarget", 200f);
    }
//	FieldOfView fov;

    // 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)
    {
        roomba = animator.GetComponent <RoombaBehaviour> ();
//		fov = animator.GetComponent<FieldOfView> ();
        roomba.StartAim();
        // turn on aim laser
        roomba.TurnOnAim();
    }
    // 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)
    {
        roomba = animator.GetComponent <RoombaBehaviour> ();
        roomba.ResetVelocity();

        switch (roomba.cs.controller)
        {
        case Controller.Boss:
            roomba.SetPlayerTargets(animator.transform);
            break;

        case Controller.Hacker:
            roomba.SetEnemyTargets(animator.transform);
            break;
        }
    }
Beispiel #4
0
    void HitRoombaBehaviour(Collider2D coll)
    {
        Transform targetTrans = coll.transform;

        ControlStatus cs = targetTrans.GetComponentInParent <ControlStatus> ();

        if (!cs)
        {
            return;
        }
        if (NotControlled(targetTrans))
        {
            // it the door is not controlled by the boss...
            RoombaBehaviour roomba = targetTrans.GetComponent <RoombaBehaviour> ();
            if (roomba)
            {
                roomba.incomingVelocity = (targetTrans.position - transform.position).normalized;
            }

            targetTrans.GetComponentInParent <ControlStatus> ().controller = Controller.Hacker;
        }
    }
    // 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)
    {
        roomba = animator.GetComponent <RoombaBehaviour> ();
        roomba.TryStartExplosion();
//		hs = animator.GetComponent<HealthSystem> ();
//		if(hs){
//			hs.InstantDead ();
//		}
//
//		roomba.body.velocity = Vector3.zero;
//
//		if(roomba.explosion != null){
//			GameObject explosionGO = Instantiate (roomba.explosion, roomba.transform.position,
//				Quaternion.Euler (0f, 0f, 0f), roomba.explosionParent);
//			ParticleLayerSetter setter = explosionGO.GetComponentInChildren<ParticleLayerSetter> ();
//			SpriteRenderer sr = animator.GetComponent<SpriteRenderer> ();
//
//			if(setter && sr){
//				setter.SetSortingLayer (sr.sortingLayerID);
//			}
//			Destroy (animator.gameObject);
//		}
    }
    void HitRoombaBehaviour(Collision2D coll)
    {
        Transform targetTrans = coll.transform;

        ControlStatus cs = targetTrans.GetComponentInParent <ControlStatus> ();

        if (!cs)
        {
            return;
        }
        if (NotControlled(targetTrans))
        {
            // it the door is not controlled by the boss...
            RoombaBehaviour roomba = targetTrans.GetComponent <RoombaBehaviour> ();
            if (roomba)
            {
                Debug.Log(initVelocity);
                roomba.incomingVelocity = initVelocity;
            }

            targetTrans.GetComponentInParent <ControlStatus> ().controller = Controller.Hacker;
        }
    }