void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Checkpoint" && other.transform.GetChild(0).position.y > checkpoint.y)
     {
         checkpoint = other.transform.GetChild(0).position;
         AudioManager.instance.Play("hooray");
     }
     else if (other.gameObject.tag == "Goal")
     {
         OnReachedGoal?.Invoke();
         GoalReached();
     }
 }
Exemple #2
0
    private void NavigateACO()
    {
        if (m_currentTargetACOConn != null)
        {
            /// Look at next target node
            GameObject targetNodeObj = m_currentTargetACOConn.Route[m_currentACOConnRouteIndex].ToNode;
            PerformLookAt(targetNodeObj.transform);

            if (!IsWaiting)
            {
                /// if not waiting, move toward next route node
                PerformMovementTo(targetNodeObj.transform.position);

                /// Check if agent reached next route node
                float nextNodeDistance = Vector3.Distance(transform.position, targetNodeObj.transform.position);
                if (nextNodeDistance < DESTINATION_TOLERANCE)
                {
                    /// Reached next route node, increment to next route node or to new ACOConnection
                    m_currentACOConnRouteIndex++;

                    /// Check RouteIndex is within route bounds
                    if (m_currentACOConnRouteIndex >= m_currentTargetACOConn.Route.Count)
                    {
                        /// If index is more than route, we've reached end and can move to next ACOConnection
                        m_currentACOConnRouteIndex = 0;

                        m_currentTargetACOConnIndex++;
                        /// Check if reached end of ACOConnection path
                        if (m_currentTargetACOConnIndex >= m_acoConnectionPath.Count)
                        {
                            ACOConnection finalConnection = m_acoConnectionPath[m_acoConnectionPath.Count - 1];
                            OnReachedPathEnd?.Invoke(this, finalConnection.ToNode);

                            m_ui.SetStatusText($"Finished path to '{finalConnection.ToNode.name}'");

                            m_currentDrivePathTarget = NavigationTarget.ACOToStart;
                            Debug.Log($"Agent '{this.name}' finished ACO path. Navigating A* path to Start");

                            return;
                        }
                        else
                        {
                            /// Move to next node in Route
                            //Debug.Log($"Reached ACO goal {m_currentTargetACOConn.ToNode.name}");

                            OnReachedGoal?.Invoke(this, m_currentTargetACOConn.ToNode);

                            /// Continue moving through ACOConnection path if not at end
                            m_currentTargetACOConn = m_acoConnectionPath[m_currentTargetACOConnIndex];

                            OnTravelNewConnection?.Invoke(this, m_currentTargetACOConn);
                            return;
                        }
                    }
                    else
                    {
                        /// Still more Route nodes to travel to, invoke event to specify the connection
                        Connection nextRouteConnection = m_currentTargetACOConn.Route[m_currentACOConnRouteIndex];
                        OnTravelNewConnection?.Invoke(this, nextRouteConnection);
                    }
                }
            }
        }
    }
Exemple #3
0
    public void ActOnTurn()
    {
        CanTakeAction      |= (Me == Player.Instance.Me);
        CanTakeBonusAction |= (Me == Player.Instance.Me);

        if (Stealth.IsHiding)
        {
            Stealth.Hide(); // re-up the Stealth CR for the round; TODO: account for obscurity at the new location, etc
        }

        if (Stealth.IsPerforming)
        {
            Stealth.Performance(); // re-up the Performance CR
        }

        Decider.ChooseState();

        switch (Decider.state)
        {
        case Decider.State.BadlyInjured:
            OnBadlyInjured?.Invoke();
            break;

        case Decider.State.Crafting:
            OnCrafting?.Invoke();
            break;

        case Decider.State.FriendsInNeed:
            OnFriendsInNeed?.Invoke();
            break;

        case Decider.State.FriendlyActorsSighted:
            OnFriendlyActorsSighted?.Invoke();
            break;

        case Decider.State.DamagedFriendlyStructuresSighted:
            OnDamagedFriendlyStructuresSighted?.Invoke();
            break;

        case Decider.State.FullLoad:
            OnFullLoad?.Invoke();
            break;

        case Decider.State.Harvesting:
            OnHarvesting?.Invoke();
            break;

        case Decider.State.HasObjective:
            OnHasObjective?.Invoke();
            break;

        case Decider.State.HostileActorsSighted:
            OnHostileActorsSighted?.Invoke();
            break;

        case Decider.State.HostileStructuresSighted:
            OnHostileStructuresSighted?.Invoke();
            break;

        case Decider.State.Idle:
            OnIdle?.Invoke();
            break;

        case Decider.State.InCombat:
            OnInCombat?.Invoke();
            break;

        case Decider.State.Medic:
            OnMedic?.Invoke();
            break;

        case Decider.State.MovingToGoal:
            OnMovingToGoal?.Invoke();
            break;

        case Decider.State.NeedsRest:
            OnNeedsRest?.Invoke();
            break;

        case Decider.State.ReachedGoal:
            OnReachedGoal?.Invoke();
            break;

        case Decider.State.Resting:
            OnResting?.Invoke();
            break;

        case Decider.State.UnderAttack:
            OnUnderAttack?.Invoke();
            break;

        case Decider.State.Watch:
            OnWatch?.Invoke();
            break;

        default:
            OnIdle?.Invoke();
            break;
        }
    }