コード例 #1
0
ファイル: GameManager.cs プロジェクト: maygarrett/Dodgeball
    // Use this for initialization
    void Start()
    {
        _agentControllers = _plane.GetComponents <AIAgentController>();

        _playerController      = _player.GetComponent <PlayerController>();
        _playerAgentController = GetPlayerAgentController();
    }
コード例 #2
0
    public void GotHit(AIAgentController attacker, GameObject ball)
    {
        // check to see if they catch the ball
        bool tempCatch = isACatch();

        if (attacker != this)
        {
            // if they catch
            if (tempCatch)
            {
                _currentBallTarget = ball;
                PickUpBall();
                if (!attacker)
                {
                    gameManager.PlayerEliminated();
                }
            }

            // if not
            else
            {
                Eliminate(this);
            }
        }
        else
        {
            ball.GetComponent <BallProjectile>()._lastThrower = this;
        }
    }
コード例 #3
0
ファイル: Agent.cs プロジェクト: joshuacassidygrant/tofu3d
 public void SetController(AIAgentController controller)
 {
     Controller = controller;
     foreach (AgentAction action in Actions)
     {
         (action).AgentSensor = (AgentSensor)controller.GetSensor();
     }
 }
コード例 #4
0
ファイル: Agent.cs プロジェクト: maygarrett/Dodgeball
    // Use this for initialization
    void Start()
    {
        m_rb = GetComponent <Rigidbody>();
        DetermineAgentColour();
        linearSpeed  = 6.0f;
        angularSpeed = 3.0f;

        _agentController = FindAgentController();
    }
コード例 #5
0
 public void Eliminate(AIAgentController playerEliminated)
 {
     // eliminate player from the game
     Debug.Log(playerEliminated.m_agent.gameObject + " is eliminated");
     Destroy(playerEliminated.m_agent.gameObject);
     playerEliminated.enabled = false;
     gameManager.CheckPlayers(playerEliminated);
     this.enabled = false;
 }
コード例 #6
0
        public void OnThingSelectionChanged()
        {
            AIAgentController agent = (AIAgentController)director.AgentWithFocus;

            if (thingOfInterestDropdown.value == 0)
            {
                agent.Target = null;
            }
            else
            {
                agent.Target = thingsManager.allTheThings[thingOfInterestDropdown.value - 1].transform;
            }
        }
コード例 #7
0
        private void LateUpdate()
        {
            AIAgentController agent = (AIAgentController)director.AgentWithFocus;
            Thing             thing = agent.Target ? agent.Target.GetComponentInParent <Thing>() : null;

            if (thing)
            {
                thingOfInterestDropdown.value = thingsManager.allTheThings.FindIndex(x => x == thing) + 1;
            }
            else
            {
                thingOfInterestDropdown.value = 0;
            }
        }
コード例 #8
0
ファイル: GameManager.cs プロジェクト: maygarrett/Dodgeball
    private AIAgentController GetPlayerAgentController()
    {
        AIAgentController[] players = _plane.GetComponents <AIAgentController>();

        AIAgentController playerAgent = null;

        for (int i = 0; i < players.Length; i++)
        {
            if (players[i].m_agent.gameObject == _player)
            {
                playerAgent = players[i];
            }
        }

        return(playerAgent);
    }
コード例 #9
0
        private void Update()
        {
            PopulateInterestingThingsDropdown();

            AIAgentController agent = (AIAgentController)director.AgentWithFocus;
            Thing             thing = agent.Target ? agent.Target.GetComponentInParent <Thing>() : null;

            if (thing)
            {
                distanceToThingOfInterestText.text = "Distance: " + Vector3.Distance(agent.transform.position, thing.AgentViewingTransform.position).ToString();
            }
            else
            {
                distanceToThingOfInterestText.text = "Wandering";
            }
        }
コード例 #10
0
ファイル: GameManager.cs プロジェクト: maygarrett/Dodgeball
    public void CheckPlayers(AIAgentController mostRecentElimination)
    {
        Debug.Log("checking players to see if alive");
        int blueTeam = 0;
        int redTeam  = 0;

        Agent[] players = FindObjectsOfType <Agent>();
        Debug.Log("found " + players.Length + " players");
        foreach (Agent player in players)
        {
            if (player.gameObject == mostRecentElimination.m_agent.gameObject)
            {
                continue;
            }

            Debug.Log("player " + player.gameObject.name + " is still alive");

            if (player._isBlue)
            {
                blueTeam++;
                Debug.Log("adding one to blue team");
            }
            else
            {
                redTeam++;
                Debug.Log("adding one to red team");
            }
        }

        _blueScore.text = blueTeam.ToString();
        _redScore.text  = redTeam.ToString();

        if (blueTeam == 0)
        {
            Debug.Log("red team wins");
            string winner = "Red Team Wins";
            GameOver(winner);
        }
        else if (redTeam == 0)
        {
            Debug.Log("blue team wins");
            string winner = "Blue Team Wins";
            GameOver(winner);
        }
    }
コード例 #11
0
ファイル: Agent.cs プロジェクト: maygarrett/Dodgeball
    private AIAgentController FindAgentController()
    {
        AIAgentController[] controllers         = _plane.GetComponents <AIAgentController>();
        AIAgentController   thisAgentController = null;


        if (controllers.Length > 0)
        {
            for (int i = 0; i < controllers.Length; i++)
            {
                if (controllers[i].m_agent == this)
                {
                    thisAgentController = controllers[i];
                }
            }
        }

        return(thisAgentController);
    }
コード例 #12
0
        public void OnAddThingClicked()
        {
            AIAgentController agent = (AIAgentController)director.AgentWithFocus;

            Thing newThing = GameObject.Instantiate <Thing>(addableThings[0]);

            newThing.name = "This is " + transform.position.ToString();
            Vector3 position = agent.transform.position;

            position.y  = Terrain.activeTerrain.SampleHeight(position) - 0.1f;
            position.x -= 0.1f;
            position.z -= 0.1f;
            newThing.transform.position = position;

            Vector3 lookAt = Camera.main.transform.position;

            newThing.transform.LookAt(new Vector3(lookAt.x, newThing.transform.position.y, lookAt.z));

            thingsManager.allTheThings.Add(newThing);
        }
コード例 #13
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Ground")
        {
            _isThrown    = false;
            _lastThrower = null;
            _isHeld      = false;
        }

        if (collision.gameObject.tag == "Agent")
        {
            if (_isThrown)
            {
                Debug.Log(collision.gameObject.name + " got Hit");
                collision.gameObject.GetComponent <Agent>()._agentController.GotHit(_lastThrower, gameObject);
                _isThrown    = false;
                _lastThrower = null;
                _isHeld      = false;
            }
        }
    }
コード例 #14
0
 public override void OnEnter()
 {
     agent.Mood        = Agent.EMood.Angry;
     m_agentController = agent.GetComponent <AIAgentController>();
     Debug.Assert(m_agentController != null, "MISSING AGENT CONTROLLER");
 }