Пример #1
0
 private Waypoint GetForwardDirectionWaypoint(BotMovement bot, Vector3 nextPosition)
 {
     return(board.GetNearestWaypoint(new Vector2Int(
                                         Mathf.RoundToInt(nextPosition.x + bot.transform.forward.x),
                                         Mathf.RoundToInt(nextPosition.z + bot.transform.forward.z)
                                         )));
 }
Пример #2
0
 public void submitTurn(BotMovement player)
 {
     for (int i = players.Count - 1; i >= 0; i--)
     {
         if (players[i] != null && GameObject.ReferenceEquals(player.gameObject, players[i].gameObject))
         {
             players.Remove(players[i]);
         }
     }
     if (players.Count == 0)
     {
         if (obstaclesActivated)
         {
             onActivateCollectibles();                 //TODO Make sure these two don't run simultaneously (in case there is a push feature for the laser)
             onFireLasers();
             obstaclesActivated = false;
             nextTurn();
         }
         else
         {
             obstaclesActivated = true;
             onActivateObstacles();
         }
     }
 }
Пример #3
0
    public ArrayList LoseBots(int num, Transform destination)
    {
        ArrayList botsUsed = new ArrayList();
        int       numToUse = num;

        if (num > bots)
        {
            return(null);
        }
        for (int i = 0; i < totalBots.Count; i++)
        {
            GameObject  bot       = totalBots[i];
            BotMovement botScript = bot.GetComponent <BotMovement>();
            if (botScript.GetState() == BotMovement.BotMode.Follow || botScript.GetState() == BotMovement.BotMode.Stopped)
            {
                botScript.SetDest(destination);
                botScript.SetState(BotMovement.BotMode.Build);
                numToUse--;
                botsUsed.Add(i);
                if (numToUse == 0)
                {
                    break;
                }
            }
        }
        bots -= num;
        overlayScript.setNumBots(bots);
        return(botsUsed);
    }
Пример #4
0
    /// <summary>
    /// задает изначальную цель бота и инициализирует переменные 
    /// </summary>
    void Start()
    {
        target = homePoint[1];

        motor = this.GetComponent<BotMovement>();
        eh = this.GetComponent<BotHealth>();
    }
Пример #5
0
        public void endTurnTrigger(BotMovement bot)
        {
            TurnManager turnManager = FindObjectOfType <TurnManager>();
            Deck        deck        = bot.GetComponent <Deck>();

            deck.DiscardCard(spamCard);
            turnManager.AddPlayerToQueue(bot);
        }
Пример #6
0
        //TODO Move collided bot in front of current bot
        void OnTriggerEnter(Collider other)
        {
            BotMovement currentBot = other.GetComponent <BotMovement>();

            if (currentBot)
            {
                currentBot.GetComponent <GridPositionHandler>().CurrentWaypoint = this;
            }
        }
Пример #7
0
        public IBotMovementHandler CreateMovement(BotMovement movement)
        {
            if (movements.ContainsKey(movement))
            {
                return((IBotMovementHandler)Activator.CreateInstance(movements[movement]));
            }

            throw new Exception($"Bot movement handler not registered movement:{movement}");
        }
Пример #8
0
    public void Start()
    {
        netChar     = gameObject.GetComponent <NetworkCharacter> ();
        cam         = gameObject.GetComponentInChildren <Camera> ();
        botCam      = gameObject.GetComponentInChildren <Camera> ();
        botMovement = gameObject.GetComponent <BotMovement> ();


        grudveBroj = 5;
        anim       = GetComponent <Animator> ();

        oldcullinMask = cam.cullingMask;
    }
Пример #9
0
        public void endTurnTrigger(BotMovement bot)
        {
            BoardProcessor board          = FindObjectOfType <BoardProcessor>();
            TurnManager    turnManager    = FindObjectOfType <TurnManager>();
            Vector3        botPosition    = bot.transform.position;
            Waypoint       moveToWaypoint = board.GetNearestWaypoint(new Vector2Int(
                                                                         Mathf.RoundToInt(botPosition.x + transform.forward.x * moveSpaces),
                                                                         Mathf.RoundToInt(botPosition.z + transform.forward.z * moveSpaces)
                                                                         ));

            if (moveToWaypoint != null)
            {
                bot.AddCommandToQueue(new Command("MOVE", moveToWaypoint));
            }
            turnManager.AddPlayerToQueue(bot);
        }
Пример #10
0
 // Stop when colliding with another bot that's stopped
 private void BumpBot(BotMovement botScript)
 {
     if (botScript != null)
     {
         if (botScript.GetState() == BotMode.Stopped)
         {
             anim.SetBool("Walking", false);
             if (navMeshAgent.enabled)
             {
                 navMeshAgent.isStopped = true;
             }
             botMode   = BotMode.Stopped;
             bumpedBot = botScript;
         }
     }
 }
Пример #11
0
        //Draw a random card, play it, then discard it
        public override void Use(BotMovement bot)
        {
            Deck deck = bot.GetComponent <Deck>();
            List <CardConfig> cards = deck.DrawCards(1);

            if (cards.Count == 1)
            {
                CardConfig card = cards[0];
                card.AttachAbilityTo(bot.gameObject);
                card.Use(bot);
                if (!card.DestroyCardAfterPlaying)
                {
                    deck.DiscardCard(card);
                }
                Destroy(this);
            }
        }
Пример #12
0
 void OnTriggerStay(Collider c)
 {
     if (c.gameObject.CompareTag("Bot") && botMode == BotMode.Follow)
     {
         BotPart botPart = c.GetComponent <BotPart>();
         if (botPart != null)
         {
             GameObject bot = botPart.GetParentBot();
             if (bot != null)
             {
                 BotMovement botScript = bot.GetComponent <BotMovement>();
                 if (botScript != null)
                 {
                     BumpBot(botScript);
                 }
             }
         }
     }
 }
Пример #13
0
 public void RegainBots(int num, ArrayList botList, Vector3 buildPadPosition, bool isSwitch)
 {
     for (int i = 0; i < botList.Count; i++)
     {
         GameObject  usedBot   = totalBots[(int)botList[i]];
         BotMovement botScript = usedBot.GetComponent <BotMovement>();
         usedBot.SetActive(true);
         if (botScript != null)
         {
             if (!isSwitch)
             {
                 botScript.JumpToPad(buildPadPosition);
             }
             else
             {
                 botScript.ReactivateNavMeshAgent();
             }
             botScript.SetState(BotMovement.BotMode.Follow);
         }
     }
     bots += num;
     overlayScript.setNumBots(bots);
 }
Пример #14
0
        //TODO Consider more elegant solution to reverse movement
        public override void Use(BotMovement bot)
        {
            board = FindObjectOfType <BoardProcessor>();
            Vector3 previousPosition = bot.transform.position;

            for (int i = 0; i < (config as MoveConfig).MoveSpaces; i++)
            {
                Waypoint nextWaypoint;
                if ((config as MoveConfig).ReverseMovement)
                {
                    nextWaypoint = GetBackwardDirectionWaypoint(bot, previousPosition);
                }
                else
                {
                    nextWaypoint = GetForwardDirectionWaypoint(bot, previousPosition);
                }
                if (nextWaypoint != null)
                {
                    MoveBot(bot, nextWaypoint);
                    previousPosition = nextWaypoint.transform.position;
                }
            }
            Destroy(bot.GetComponent <MoveBehavior>());
        }
Пример #15
0
 void OnTriggerEnter(Collider c)
 {
     if (c.gameObject.CompareTag("Player") && c.attachedRigidbody != null)
     {
         //NOTE: inventory script was deleted if more problems arise. This is what we changed
         //InventoryScript invent = c.attachedRigidbody.gameObject.GetComponent<InventoryScript>();
         if (/*invent != null &&*/ botMode == BotMode.Idle)
         {
             botMode = BotMode.Follow;
             anim.SetBool("BootUp", true);
             BotCollector bc = c.attachedRigidbody.gameObject.GetComponent <BotCollector>();
             if (bc != null)
             {
                 bc.ReceiveBots(1, transform.gameObject);
             }
             followTarget = c.attachedRigidbody.transform;
             //invent.AddBot();
         }
     }
     else if (c.gameObject.CompareTag("BotPart") && botMode == BotMode.Follow)
     {
         BotPart botPart = c.GetComponent <BotPart>();
         if (botPart != null)
         {
             GameObject bot = botPart.GetParentBot();
             if (bot != null)
             {
                 BotMovement botScript = bot.GetComponent <BotMovement>();
                 if (botScript != null)
                 {
                     BumpBot(botScript);
                 }
             }
         }
     }
 }
Пример #16
0
 public void Use(BotMovement bot)
 {
     behavior.Use(bot);
 }
Пример #17
0
 public override void Use(BotMovement bot)
 {
     bot.AddCommandToQueue(new Command("ROTATE", null, (config as RotateConfig).NumRotations));
     Destroy(bot.GetComponent <RotateBehavior>());
 }
Пример #18
0
 public void RemovePlayerFromQueue(BotMovement player)
 {
     players.Remove(player);
 }
Пример #19
0
 private void MoveBot(BotMovement bot, Waypoint nextWaypoint)
 {
     bot.AddCommandToQueue(new Command("MOVE", nextWaypoint));
 }
Пример #20
0
 public void AddPlayerToQueue(BotMovement newPlayer)
 {
     players.Add(newPlayer);
 }
Пример #21
0
 public GoToDropzoneEffect(BotMovement botMovement, Transform dropzonePoint, float speed)
 {
     this.botMovement   = botMovement;
     this.dropzonePoint = dropzonePoint;
     this.speed         = speed;
 }
Пример #22
0
 // Use this for initialization
 void Start()
 {
     movement = GetComponent <BotMovement>();
 }
Пример #23
0
    void OnCollisionEnter(Collision col)
    {
        Debug.Log("OnColEnter" + PhotonNetwork.player.name);

        if (col.gameObject.tag == "Untagged" || col.gameObject.tag == "MyPlayer" || col.gameObject.tag == "Head" || col.gameObject.tag == "Legs" || col.gameObject.tag == "Stomach" || col.gameObject.tag == "BOT")
        {
            Instantiate(snegOstaci, col.contacts [0].point, Quaternion.identity);
            Explode();
        }



        /*if (col.gameObject.tag == "MyPlayer") {
         *      Health h = col.gameObject.GetComponentInParent<Health> ();
         *      Debug.Log ("We hit us");
         *      if (h != null) {
         *              //h.TakeDamage (HeadDMG);
         *              h.GetComponent<PhotonView> ().RPC ("TakeDamage", PhotonTargets.AllBuffered, HeadDMG);
         *              Debug.Log (h.HealthPoints);
         *      }
         * }*/

        if (col.gameObject.tag == "MyPlayer")
        {
            Explode();
        }


        if (col.gameObject.tag == "BobsBack")
        {
            Health h = col.gameObject.GetComponentInParent <Health> ();
            Debug.Log("We hit enemys chest");
            if (h != null)
            {
                //h.TakeDamage(ChestDMG);
                h.GetComponent <PhotonView> ().RPC("TakeDamage", PhotonTargets.All, BobsBackDMG);



                /*if(h.HealthPoints < 0)  {
                 *
                 *      scoreManager.GetComponent<PhotonView> ().RPC ("killsUp", PhotonTargets.AllBufferedViaServer, nick);
                 * }*/
            }
        }


        if (col.gameObject.tag == "Stomach")
        {
            Sounds s = col.gameObject.GetComponentInParent <Sounds> ();
            Health h = col.gameObject.GetComponentInParent <Health> ();
            Debug.Log("We hit enemys stomach");

            if (h != null)
            {
                h.GetComponent <PhotonView> ().RPC("TakeDamage", PhotonTargets.All, StomachDMG);
                if (h.HealthPoints < 0)
                {
                    scoreManager.GetComponent <PhotonView> ().RPC("test", PhotonTargets.AllBuffered, nick);
                }
            }
            if (netManager.Boy == true && netManager.Bob == false && netManager.Girl == false)
            {
                s.DamageBoy();
            }
            if (netManager.Bob == true && netManager.Boy == false && netManager.Girl == false)
            {
                s.DamageBob();
            }
            if (netManager.Girl == true && netManager.Boy == false && netManager.Bob == false)
            {
                s.DamageGirl();
            }
        }


        if (col.gameObject.tag == "Head")
        {
            Sounds s = col.gameObject.GetComponentInParent <Sounds> ();
            Health h = col.gameObject.GetComponentInParent <Health> ();
            Debug.Log("Headshot!");


            if (h != null)
            {
                h.GetComponent <PhotonView> ().RPC("TakeDamage", PhotonTargets.All, HeadDMG);
                if (h.HealthPoints < 0)
                {
                    scoreManager.GetComponent <PhotonView> ().RPC("test", PhotonTargets.AllBuffered, nick);
                }
                h.HeadShotAnim();
            }

            if (netManager.Boy == true && netManager.Bob == false && netManager.Girl == false)
            {
                s.DamageBoy();
            }
            if (netManager.Bob == true && netManager.Boy == false && netManager.Girl == false)
            {
                s.DamageBob();
            }
            if (netManager.Girl == true && netManager.Boy == false && netManager.Bob == false)
            {
                s.DamageGirl();
            }
        }


        if (col.gameObject.tag == "Leg")
        {
            Sounds s = col.gameObject.GetComponentInParent <Sounds> ();
            Health h = col.gameObject.GetComponentInParent <Health> ();
            Debug.Log("We hit enemys leg");

            if (h != null)
            {
                h.GetComponent <PhotonView> ().RPC("TakeDamage", PhotonTargets.All, LegDMG);
                if (h.HealthPoints < 0)
                {
                    scoreManager.GetComponent <PhotonView> ().RPC("test", PhotonTargets.AllBuffered, nick);
                }
            }

            if (netManager.Boy == true && netManager.Bob == false && netManager.Girl == false)
            {
                s.DamageBoy();
            }
            if (netManager.Bob == true && netManager.Boy == false && netManager.Girl == false)
            {
                s.DamageBob();
            }
            if (netManager.Girl == true && netManager.Boy == false && netManager.Bob == false)
            {
                s.DamageGirl();
            }
        }
        if (col.gameObject.tag == "BOT")
        {
            BotMovement bt = col.gameObject.GetComponentInParent <BotMovement> ();
            if (bt != null)
            {
                bt.Damage();

                if (bt.HealthPoints <= 0f)
                {
                    scoreManager.GetComponent <PhotonView> ().RPC("test", PhotonTargets.AllBuffered, nick);
                }
            }
        }
    }
Пример #24
0
 void Update()
 {
     if (navMeshAgent.isOnOffMeshLink && !jumping)
     {
         StartCoroutine(JumpOffMesh());
     }
     if (botMode == BotMode.Follow)
     {
         if (navMeshAgent.enabled)
         {
             if (Vector3.Distance(FlattenTransform(followTarget.position), FlattenTransform(navMeshAgent.destination)) > 0.5f)
             {
                 if (!navMeshAgent.pathPending)
                 {
                     navMeshAgent.SetDestination((followTarget.position));
                 }
                 anim.SetBool("IsBlock", false);
                 anim.SetBool("Walking", true);
                 if (navMeshAgent.isStopped)
                 {
                     anim.SetBool("Walking", false);
                     botMode = BotMode.Stopped;
                 }
             }
             else if (navMeshAgent.remainingDistance <= 3f)
             {
                 anim.SetBool("Walking", false);
                 navMeshAgent.isStopped = true;
                 botMode = BotMode.Stopped;
             }
         }
     }
     else if (botMode == BotMode.Stopped)
     {
         if (bumpedBot != null)
         {
             if (bumpedBot.GetState() != BotMode.Stopped)
             {
                 bumpedBot = null;
                 botMode   = BotMode.Follow;
             }
         }
         else
         {
             if (Vector3.Distance(FlattenTransform(followTarget.position), FlattenTransform(navMeshAgent.destination)) > 0.5f)
             {
                 navMeshAgent.isStopped = false;
                 anim.SetBool("Walking", true);
                 botMode = BotMode.Follow;
             }
         }
     }
     if (botMode == BotMode.Build)
     {
         if (!jumping)
         {
             if (!readyToBuild)
             {
                 Collider[] colliders = gameObject.GetComponentsInChildren <Collider>();
                 foreach (Collider c in colliders)
                 {
                     c.enabled = false;
                 }
                 if (navMeshAgent.enabled)
                 {
                     navMeshAgent.isStopped = true;
                 }
                 StartCoroutine(JumpToBuild());
             }
             else
             {
                 readyToBuild = false;
                 transform.gameObject.SetActive(false);
             }
         }
     }
     if (gameObject.activeSelf)
     {
         anim.SetFloat("Y", navMeshAgent.velocity.magnitude / navMeshAgent.speed);
     }
 }
Пример #25
0
 public GoToObjectEffect(BotMovement botMovement, ObjectPositionSensor objectPositionSensor, float speed)
 {
     this.botMovement          = botMovement;
     this.objectPositionSensor = objectPositionSensor;
     this.speed = speed;
 }
Пример #26
0
 public abstract void Use(BotMovement bot);