Example #1
0
    public void startGameMode()
    {
        List <Player> players = new List <Player>();

        players.AddRange(GameObject.FindObjectsOfType <NetworkedPlayer>());
        players.AddRange(GameObject.FindObjectsOfType <BotPlayer>());

        // Add flags
        foreach (Team team in teams)
        {
            Flag flag = team.gameObject.GetComponentInChildren <Flag>();
            flag.team = team;
            flag.setBasePosition(flag.transform.position);

            Transform   flagBase    = team.transform.Find("Flag Base");
            FlagTrigger flagTrigger = flagBase.GetComponentInChildren <FlagTrigger>();
            flagTrigger.team     = team;
            flagTrigger.teamFlag = flag;
        }

        foreach (Team team in teams)
        {
            team.resetScore();
        }

        assignTeams(players);

        foreach (Team team in teams)
        {
            team.spawnPlayers();
        }

        startGame();
    }
    void OnTriggerEnter(Collider collision)
    {
        if (collision.gameObject.CompareTag("Pick Up"))
        {
            collision.gameObject.SetActive(false);
            hasShovel = true;
        }

        Flag flag = collision.gameObject.GetComponent <Flag>();

        if (flag != null)
        {
            pickUp(flag);
        }

        FlagTrigger flagTrigger = collision.gameObject.GetComponent <FlagTrigger>();

        if (flagTrigger != null)
        {
            flagTrigger.triggeredBy(this);
        }

        Snowman snowman = collision.gameObject.GetComponent <Snowman>();

        if (snowman != null)
        {
            Debug.Log("Press Action button to enter snowman");
            snowmanToEnter = snowman;
        }
    }
Example #3
0
    public void OnFlagTriggerStay(FlagTrigger trigger, Collider2D collision)
    {
        // ignore while hidden or captured
        if (!flagIsUp || flagCaptured)
        {
            return;
        }

        switch (trigger.tag)
        {
        case "TriggerZone":
            if (collision.CompareTag("Player"))
            {
                activeBehavior.OnPlayerInTriggerZone();
            }
            break;

        case "FieldOfVision":
            if (collision.CompareTag("Player"))
            {
                activeBehavior.OnPlayerInFieldOfVision();
            }
            break;

        case "CaptureZone":
            if (collision.CompareTag("PlayerFoV"))
            {
                activeBehavior.OnPlayerLookingAtFlag();
            }
            break;
        }
    }
Example #4
0
    /// <summary>
    /// Player has entered the
    ///     - "trigger" zone
    ///     - field of vision
    ///     - capture zone
    /// </summary>
    /// <param name="trigger"></param>
    /// <param name="collision"></param>
    public void OnFlagTriggerEntered(FlagTrigger trigger, Collider2D collision)
    {
        if (!flagIsUp || flagCaptured)
        {
            return;
        }

        if (trigger.CompareTag("CaptureZone") && collision.CompareTag("Player"))
        {
            activeBehavior.OnPlayerTouchesFlag();
        }
        else
        {
            OnFlagTriggerStay(trigger, collision);
        }
    }
Example #5
0
    /// <summary>
    /// Player no longer in:
    ///     - Field of view
    /// Player's FoV no longer in:
    ///     - Field of view
    ///     - Capture zone
    /// </summary>
    /// <param name="trigger"></param>
    /// <param name="collision"></param>
    public void OnFlagTriggerExit(FlagTrigger trigger, Collider2D collision)
    {
        switch (trigger.tag)
        {
        case "FieldOfVision":
            if (collision.CompareTag("Player"))
            {
                activeBehavior.OnPlayerNotInFieldOfVision();
            }
            break;

        case "CaptureZone":
            if (collision.CompareTag("PlayerFoV"))
            {
                activeBehavior.OnPlayerNotLookingAtFlag();
            }
            break;
        }
    }