Esempio n. 1
0
    public float attackRange    = 2f;   // How far ahead we can atta

    // Start is called before the first frame update
    new void Start()
    {
        base.Start();
        // Get references
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            Debug.Log("Boss Animator could not be found");
        }
        visionRange = GetComponent <ConeCollider>();
        if (visionRange == null)
        {
            Debug.Log("Could not find Boss vision range box collider");
        }
        attackCollider = GetComponent <SphereCollider>();
        if (attackCollider == null)
        {
            Debug.Log("Could not find Boss attack range box collider");
        }
        // Currently not attacking, it observed if player is
        attackCollider.enabled = false;
        visionRange.enabled    = true;

        // Init state machine,
        //the boss intially is in Relax state
        stateMachine = new FSM();
        State_BossRelax state = new State_BossRelax(this);

        state.SetAnimator(anim);

        stateMachine.SetState(state);
    }
 void OnEnable()
 {
     SetProperty(ref m_angle, "m_angle");
     SetProperty(ref m_distance, "m_distance");
     SetProperty(ref m_isTrigger, "m_isTrigger");
     SetProperty(ref m_isFixScale, "m_isFixScale");
     m_conecollider = target as ConeCollider;
 }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     rb             = GetComponent <Rigidbody>();
     anim           = GetComponent <Animator>();
     nav            = GetComponent <NavMeshAgent>();
     collCone       = transform.Find("cone").GetComponent <ConeCollider>();
     state          = AIState.approaching;
     fireAttackPart = transform.Find("FireBall").GetComponent <ParticleSystem>();
     em             = fireAttackPart.emission;
     em.enabled     = false;
 }
Esempio n. 4
0
    public float attackRange    = 1.2f; // How far ahead we can attack

    // Start is called before the first frame update
    new void Start()
    {
        base.Start();
        // Get references
        anim = GetComponent <Animator>();
        if (anim == null)
        {
            Debug.Log("Animator could not be found");
        }
        visionRange = GetComponent <ConeCollider>();
        if (visionRange == null)
        {
            Debug.Log("Could not find cone collider");
        }
        attackCollider = GetComponent <CapsuleCollider>();
        if (attackCollider == null)
        {
            Debug.Log("Could not find capsule collider");
        }
        navAgent = GetComponent <NavMeshAgent>();
        if (navAgent == null)
        {
            Debug.Log("Could not find nav mesh agent");
        }
        // Set the attack capsule's range
        attackCollider.radius    = attackRange;
        attackCollider.isTrigger = true;
        // Currently not attacking
        attackCollider.enabled = false;
        visionRange.enabled    = true;

        // Init list of checkpoints
        checkpoints  = new List <Vector3>();
        ticksToReach = new List <int>();
        // Get the list of checkpoints
        if (transform.Find("Movepoints") != null)
        {
            Transform movingPoints = transform.Find("Movepoints").gameObject.transform;
            int       numChildren  = movingPoints.childCount;
            for (int i = 0; i < numChildren; ++i)
            {
                // Get each checkpoint
                GameObject goalPoint = movingPoints.GetChild(i).gameObject;
                Checkpoint cp        = goalPoint.GetComponent(typeof(Checkpoint)) as Checkpoint;
                if (cp != null)
                {
                    checkpoints.Add(goalPoint.transform.position);
                    ticksToReach.Add(cp.GetMoveTime());
                }
            }
        }

        // Init state machine
        stateMachine = new FSM();
        State_Patrol state = new State_Patrol(this);

        state.SetAnimator(anim);
        state.SetNavAgent(navAgent);
        state.SetPatrolPoints(checkpoints, ticksToReach);
        state.currentCheckpoint = -1;

        stateMachine.SetState(state);
    }
Esempio n. 5
0
    //******************************************************************************************************************************
    //
    //      FUNCTIONS
    //
    //******************************************************************************************************************************

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    // Called when the gameObject is created.
    /// </summary>
    private void Start()
    {
        // Get component references
        _ConeCollider = GetComponent <ConeCollider>();
    }