예제 #1
0
    // The function to call when creating a clone to initialise everything
    public void Create(BaseMovement moveComponent, BaseCombat combatComponent, Vector3 startingPos, 
	                   float activeTime, GameObject target, GameObject projectilePrefab)
    {
        // Initialise the target
        m_Target = target;
        // Add a navmesh agent
        m_Agent = (NavMeshAgent) gameObject.AddComponent (Constants.NAV_AGENT);

        // Create a move component of the same type as the one passed
        System.Type movementType = moveComponent.GetType ();
        string moveType = movementType.ToString ();
        m_MovementComponent = (BaseMovement) gameObject.AddComponent (moveType);

        // Set the agent of that move component
        if (m_MovementComponent != null)
            m_MovementComponent.SetAgent (m_Agent);

        //Create a combat component of the same type as the one passed
        System.Type combatType = combatComponent.GetType ();
        string comType = combatType.ToString ();
        m_CombatComponent = (BaseCombat) gameObject.AddComponent (comType);

        // Initialise the projectile prefab
        if (m_CombatComponent != null)
            m_CombatComponent.SetProjectilePrefab (projectilePrefab);

        // Set the active timer
        m_ActiveTimer = activeTime;

        // move to the starting attack position
        if (m_MovementComponent != null)
            m_MovementComponent.Movement (startingPos);

        m_Health = 0.5f;
    }
예제 #2
0
    // The function to call when creating a clone to initialise everything
    public void Create(BaseMovement moveComponent, BaseCombat combatComponent, Vector3 startingPos,
                       float activeTime, GameObject target, GameObject projectilePrefab)
    {
        // Initialise the target
        m_Target = target;
        // Add a navmesh agent
        m_Agent = (NavMeshAgent)gameObject.AddComponent(Constants.NAV_AGENT);

        // Create a move component of the same type as the one passed
        System.Type movementType = moveComponent.GetType();
        string      moveType     = movementType.ToString();

        m_MovementComponent = (BaseMovement)gameObject.AddComponent(moveType);

        // Set the agent of that move component
        if (m_MovementComponent != null)
        {
            m_MovementComponent.SetAgent(m_Agent);
        }

        //Create a combat component of the same type as the one passed
        System.Type combatType = combatComponent.GetType();
        string      comType    = combatType.ToString();

        m_CombatComponent = (BaseCombat)gameObject.AddComponent(comType);

        // Initialise the projectile prefab
        if (m_CombatComponent != null)
        {
            m_CombatComponent.SetProjectilePrefab(projectilePrefab);
        }

        // Set the active timer
        m_ActiveTimer = activeTime;

        // move to the starting attack position
        if (m_MovementComponent != null)
        {
            m_MovementComponent.Movement(startingPos);
        }

        m_Health = 0.5f;
    }