Ejemplo n.º 1
0
    private bool GoldBodySlam()
    {
        float radius = controller.radius * 1.5f;

        Collider[] colliders = Physics.OverlapSphere(transform.position + controller.up * controller.height * 0.5f, radius);

        foreach (var col in colliders)
        {
            EnemyMachine machine = col.GetComponent <EnemyMachine>();

            if (machine != null)
            {
                if (machine.GetStruck(Math3d.ProjectVectorOnPlane(controller.up, machine.transform.position - transform.position).normalized, 7.0f, 15.0f))
                {
                    sound.PlayImpact();

                    machine.MakeGold();
                }
            }

            RollingBallGoldDestroy ball = col.GetComponent <RollingBallGoldDestroy>();

            if (ball)
            {
                ball.BlowUp();
            }
        }

        return(false);
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     col      = this.gameObject.GetComponent <Collider2D>();
     rb       = this.gameObject.GetComponent <Rigidbody2D>();
     sr       = this.gameObject.GetComponent <SpriteRenderer>();
     em       = GetComponent <EnemyMachine>();
     animator = this.gameObject.GetComponent <Animator>();
 }
Ejemplo n.º 3
0
 public PatrolState(EnemyMachine machine, Transform entity)
 {
     stateMachine    = machine;
     target          = entity;
     currentWayPoint = 0;
     wP = stateMachine.wayPoints[currentWayPoint];
     up = true;
 }
Ejemplo n.º 4
0
 //set a new destination for NavMeshAgent
 public void handleMove( EnemyMachine controller )
 {
     NavMeshAgent _mAgent = controller.GetComponent<NavMeshAgent>();
     target = controller.escapePoint[ Random.Range(0,5) ].position;
     while( oldTarget != Vector3.zero && oldTarget == target ){
         target = controller.escapePoint[ Random.Range(0,5) ].position;
     }
     oldTarget = target;
     _mAgent.speed = 10.0f;
     _mAgent.SetDestination(target);
     _mAgent.Resume();
     controller.gameObject.GetComponent<Renderer>().material = controller.materialEffect[4];
 }
Ejemplo n.º 5
0
    private bool BodySlam()
    {
        float radius = controller.radius * 1.5f;

        Collider[] colliders = Physics.OverlapSphere(transform.position, radius, EnemyLayerMask);

        foreach (var col in colliders)
        {
            EnemyMachine machine = col.GetComponent <EnemyMachine>();

            if (machine != null && machine is GoombaMachine)
            {
                if (machine.GetStruck(Math3d.ProjectVectorOnPlane(controller.up, machine.transform.position - transform.position).normalized, 7.0f, 15.0f, 0.3f))
                {
                    sound.PlayImpact();
                }
            }
        }

        return(false);
    }
Ejemplo n.º 6
0
    public void handleView( EnemyMachine controller, EnemySight mSight )
    {
        //need initial escape destination.
        if( !fire ){
            SoundManager.Instance.playIndieSingle( controller.monkeyAudioSource, controller.monkeyAudioClips[1] );
            controller.doAgentMove();
            fire = true;

        }
        else{
            //caculate if destiniation need regenerate.
            float distanceToDest = Vector3.Distance( controller.transform.position, oldTarget);
            if( distanceToDest < 1f ){
                controller.doAgentMove();
            }
        }

        if( !mSight.enemyView.PlayerAround && mSight.enemyView.leaveTime > 0){
            if(Mathf.FloorToInt(Time.time) - mSight.enemyView.leaveTime > 3 )
            controller.mBehaviouir = new SuspiciousState( oldTarget );
        }
        //Debug.Log("State :  EscapeState");
    }
Ejemplo n.º 7
0
 public void handleView( EnemyMachine controller, EnemySight mSight )
 {
 }
Ejemplo n.º 8
0
 public ShooterState(EnemyMachine machine, Transform target)
 {
     stateMachine = machine;
     this.target  = target;
 }
Ejemplo n.º 9
0
 public MonkeyDamage( EnemyMachine me, Material[] materials )
 {
     enemyMachine = me;
     defaultMaterial = materials[0];
     damageMaterial = materials[1];
 }
Ejemplo n.º 10
0
 private IEnumerator coma( EnemyMachine controller, float timeOut  )
 {
     controller.gameObject.GetComponent<NavMeshAgent>().Stop();
     yield return new WaitForSeconds(timeOut);
     controller.mBehaviouir = new SuspiciousState(Vector3.zero);
 }
Ejemplo n.º 11
0
 public void handleMove( EnemyMachine controller )
 {
 }
Ejemplo n.º 12
0
 public WalkToEntityState(EnemyMachine machine, Transform entity)
 {
     stateMachine = machine;
     target       = entity;
 }
Ejemplo n.º 13
0
    public void handleView( EnemyMachine controller, EnemySight mSight )
    {
        _mAgent = controller.GetComponent<NavMeshAgent>();
        if( !fire || !_mAgent.hasPath ){
            if( controller.monkeyAudioClips[0]!= null ){
                SoundManager.Instance.playIndieSingle( controller.monkeyAudioSource, controller.monkeyAudioClips[0] );
            }
            controller.doAgentMove();
            fire = true;

        }

        if( mSight.enemyView.PlayerSighted ){
            controller.mBehaviouir = new EscapeState();
        }
        if( mSight.enemyView.PlayerAround ){
            //controller.mBehaviouir = new SuspiciousState(oldTarget);
        }
    }
Ejemplo n.º 14
0
    public void handleView( EnemyMachine controller, EnemySight mSight )
    {
        if( !fire ){
            SoundManager.Instance.playIndieSingle( controller.monkeyAudioSource, controller.monkeyAudioClips[0] );
            controller.doAgentMove();
            fire = true;
            timeout = Mathf.FloorToInt( Time.time );
        }

        if( mSight.enemyView.PlayerAround ){
            controller.mBehaviouir = new EscapeState();

        }

        if( !mSight.enemyView.PlayerSighted && !mSight.enemyView.PlayerAround ){
            float distanceToDest = Vector3.Distance( controller.transform.position, oldTarget);

            if( Mathf.FloorToInt( Time.time ) - timeout > 3 ){
                controller.mBehaviouir = new WonderState();
            }
        }

        //Debug.Log("State :  SuspiciousState");
    }
Ejemplo n.º 15
0
    public void handleMove( EnemyMachine controller )
    {
        if( oldTarget != Vector3.zero ){

            NavMeshAgent _mAgent = controller.GetComponent<NavMeshAgent>();
            //_mAgent.SetDestination(oldTarget);
            _mAgent.speed = 2.0f;
            _mAgent.Resume();
        }
        controller.gameObject.GetComponent<Renderer>().material = controller.materialEffect[3];
    }
Ejemplo n.º 16
0
 //maintain Escape destination from escape state
 public ComaState( EnemyMachine controller )
 {
     controller.StartCoroutine( coma(controller, 3.0f) );
 }
Ejemplo n.º 17
0
 public FightState(EnemyMachine machine, Transform target)
 {
     stateMachine = machine;
     this.target  = target;
 }