Beispiel #1
0
 public void OnTriggerExit2D(Collider2D coll)
 {
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.LocalPlayerBody) || coll.gameObject.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
     {
         target = staticTarget;
     }
 }
Beispiel #2
0
 protected void DestroyBarrierRPC()
 {
     gameObject.tag = TagsManager.GetTag(Tag.DestroyedBarrier);
     destroyed      = true;
     GetComponent <SpriteRenderer>().sprite   = destroyedTexture;
     GetComponent <BoxCollider2D>().isTrigger = true;
 }
Beispiel #3
0
    public void SetBarrierOutNearList(Collider2D collision)
    {
        if (collision.GetComponent <AntiTankBarrier>() == null)
        {
            return;
        }
        if (collision.tag == TagsManager.GetTag(Tag.RepairedBarrier))
        {
            tempObiektDoZniszczenia.Remove(collision.gameObject.GetComponent <AntiTankBarrier>());
        }
        if (collision.tag == TagsManager.GetTag(Tag.DestroyedBarrier))
        {
            tempObiektDoNaprawy.Remove(collision.gameObject.GetComponent <AntiTankBarrier>());
        }

        //Wyłącza pola edycji
        if (collision.gameObject.GetComponent <AntiTankBarrier>().fieldForRepair != null)
        {
            collision.gameObject.GetComponent <AntiTankBarrier>().fieldForRepair.SetActive(false);
        }
        if (collision.gameObject.GetComponent <AntiTankBarrier>().fieldForDestroy != null)
        {
            collision.gameObject.GetComponent <AntiTankBarrier>().fieldForDestroy.SetActive(false);
        }
    }
Beispiel #4
0
 protected void RepairBarrierRPC()
 {
     destroyed      = false;
     gameObject.tag = TagsManager.GetTag(Tag.RepairedBarrier);
     GetComponent <SpriteRenderer>().sprite   = repairedTexture;
     GetComponent <BoxCollider2D>().isTrigger = false;
 }
Beispiel #5
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.LocalPlayerBody) || coll.gameObject.tag == TagsManager.GetTag(Tag.Bot))
     {
         Destroy();
     }
 }
Beispiel #6
0
 //If BOT collision he's target
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.RoadPoint))
     {
         //UnityEngine.Debug.Log("<color=blue>BOT</color>: idę za Kolejnym punktem ścieżki");
         RoadPoint roadPoint = coll.gameObject.GetComponent <RoadPoint>();
         roadPoint.ResetCollider();
         int bezpiecznik = 0;
         while (true)
         {
             int index = Random.Range(0, roadPoint.punktyDrogiObok.Length);
             if (roadPoint.punktyDrogiObok[index] != tempTargetRoad)
             {
                 tempTargetRoad = target;
                 target         = roadPoint.punktyDrogiObok[index];
                 break;
             }
             else
             {
                 bezpiecznik++;
                 if (bezpiecznik > 10)
                 {
                     //UnityEngine.Debug.Log("<color=blue>BOT</color>: koniec ścieżki");
                     tempTargetRoad = target;
                     target         = roadPoint.punktyDrogiObok[index];
                     break;
                 }
             }
         }
     }
 }
Beispiel #7
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.LocalPlayerBody) || coll.gameObject.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
     {
         target = coll.gameObject;
     }
 }
Beispiel #8
0
    void ObracajKolizyjnie()
    {
        dystansDoMyszki = Vector2.Distance(raycastStart.transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition));

        maxFirePoint.transform.localPosition = new Vector3(-dystansDoMyszki * 3f, 0f, 0f);

        Vector2      mousePosition   = new Vector2(maxFirePoint.transform.position.x, maxFirePoint.transform.position.y);
        Vector2      raycastStartPos = new Vector2(raycastStart.position.x, raycastStart.position.y);
        RaycastHit2D hit             = Physics2D.Raycast(raycastStartPos, mousePosition - raycastStartPos, dystansDoMyszki, WhatToHit);

        Debug.DrawLine(raycastStartPos, mousePosition, Color.cyan);

        if (hit.collider != null)
        {
            if (hit.collider.tag == TagsManager.GetTag(Tag.RemotePlayerBody) || hit.collider.tag == TagsManager.GetTag(Tag.Bot))
            {
                GetComponent <SpriteRenderer>().color = red;
            }
            else
            {
                GetComponent <SpriteRenderer>().color = yellow;
            }

            Debug.DrawLine(raycastStartPos, hit.point, Color.red);
            transform.position = new Vector3(hit.point.x, hit.point.y, 0f);
        }
        else
        {
            GetComponent <SpriteRenderer>().color = green;
            transform.localPosition = new Vector3(-dystansDoMyszki * 3, 0, 0);
        }
    }
Beispiel #9
0
 void CheckPlayerOutNear(Collider2D collision)
 {
     if (collision.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
     {
         gameOver.onPlayerDead -= collision.GetComponent <TankObject>().PlayerGO.GetComponent <TankDeath>().tankPeriscope.CameraShake;
         //PlayersInNear.Remove(collision.GetComponent<Keeper>().keep.GetComponent<PlayerGO>().myPlayer);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Jestem lokalnym graczem i trafiam BOTa
 /// </summary>
 /// <param name="hit"></param>
 protected void HitBotHowPlayer(RaycastHit2D hit, float damage)
 {
     if (hit.collider.tag == TagsManager.GetTag(Tag.Bot))
     {
         hit.collider.GetComponent <BOTHealt>().myPV.RPC("AdBotDamage", PhotonTargets.All, damage); //niech bot sprawdza jako czołg ma gracz
         hit.collider.GetComponent <BOTHealt>().SetLastShooter(myPV.GetComponent <PlayerGO>().myPlayer);
         hit.collider.GetComponent <BOTHealt>().SyncHP(hit.collider.GetComponent <BOTHealt>().healtPoint);
     }
 }
Beispiel #11
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == TagsManager.GetTag(Tag.StaticGameObject) ||
         collision.tag == TagsManager.GetTag(Tag.RepairedBarrier) ||
         collision.tag == TagsManager.GetTag(Tag.DestroyedBarrier))
     {
         canBuildPanel.SetActive(true);
         canNotBuildPanel.SetActive(false);
         canBuild = true;
     }
 }
Beispiel #12
0
 public void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == TagsManager.GetTag(Tag.DeepWater))
     {
         sink     = false;
         sinkTime = maxSinkTime;
         HUDManager.Instance.meltTime.text = "";
     }
     if (collision.tag == TagsManager.GetTag(Tag.Water))
     {
         swim = false;
     }
 }
Beispiel #13
0
 void OnTriggerExit2D(Collider2D coll)
 {
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.Bot) || coll.gameObject.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
     {
         if (turret.towerType == TowerType.IS7OnHead)
         {
             curretTarget = TankEvolution.Instance.BarrelEndPoint;
         }
         else
         {
             curretTarget = staticTarget;
         }
     }
 }
Beispiel #14
0
    public void Check()
    {
        RaycastHit2D hit = MakeRaycastHit2D();

        if (hit.collider != null)
        {
            if (hit.collider.tag == TagsManager.GetTag(Tag.LocalPlayerBody) || hit.collider.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
            {
                if (allow == true)
                {
                    trafie = true;
                }
            }
        }
    }
Beispiel #15
0
    /// <summary>
    /// Jestem lokalnym graczem i trafiam zdalnego
    /// </summary>
    /// <param name="hit"></param>
    protected void HitPlayerHowPlayer(RaycastHit2D hit, float damage)
    {
        if (hit.collider.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
        {
            if (hit.collider.GetComponent <TankObject>().Player.currentHp > 0)
            {
                GameManager.Instance.photonView.RPC("OdbierzHpGraczowiRPC", PhotonTargets.MasterClient,
                                                    hit.collider.GetComponent <TankObject>().Player.pp, damage);
            }

            SetCameraTargetOnMePlayer(hit);

            PlayHitAudioPlayer(hit);
        }
    }
Beispiel #16
0
 public void SetBarrierInNearList(Collider2D collision)
 {
     if (collision.GetComponent <AntiTankBarrier>() == null)
     {
         return;
     }
     if (collision.tag == TagsManager.GetTag(Tag.RepairedBarrier))
     {
         tempObiektDoZniszczenia.Add(collision.gameObject.GetComponent <AntiTankBarrier>());
     }
     if (collision.tag == TagsManager.GetTag(Tag.DestroyedBarrier))
     {
         tempObiektDoNaprawy.Add(collision.gameObject.GetComponent <AntiTankBarrier>());
     }
 }
Beispiel #17
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.tag);
        if (collision.tag == TagsManager.GetTag(Tag.DeepWater))
        {
            sink = true;

            if (!IHasBeenSinking)
            {
                StartCoroutine(TopienieCzolgu());
            }
        }
        if (collision.tag == TagsManager.GetTag(Tag.Water))
        {
            swim = true;
        }
    }
Beispiel #18
0
    //If BOT collision rock, home itp.
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (movement == true)
        {
            if (coll.gameObject.tag == TagsManager.GetTag(Tag.StaticGameObject) ||
                coll.gameObject.tag == TagsManager.GetTag(Tag.RemotePlayerBody) ||
                coll.gameObject.tag == TagsManager.GetTag(Tag.LocalPlayerBody))
            {
                SetTargetPosition();
                StartCoroutine(ChangeSpeed());
            }

            if (coll.gameObject.tag == TagsManager.GetTag(Tag.Bot))
            {
                StartCoroutine(ChangeSpeed());
            }
        }
    }
Beispiel #19
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.CompareTag(TagsManager.GetTag(Tag.LocalPlayerBody)))
     {
         HUDManager.TankTier otherPlayerTankTier = coll.gameObject.GetComponentInParent <PlayerGO>().myPlayer.tankTier;
         Debug.Log(otherPlayerTankTier);
         for (int i = 0; i < tankTiersWhichCanDestroy.Length; i++)
         {
             if (tankTiersWhichCanDestroy[i] == otherPlayerTankTier)
             {
                 Destroy();
                 TriggerSth triggerSth = coll.gameObject.GetComponentInParent <TankDeath>().triggerSth;
                 triggerSth.StartCoroutine(triggerSth.ResetColliera());
                 break;
             }
         }
     }
     if (coll.gameObject.tag == TagsManager.GetTag(Tag.Bot))
     {
         Destroy();
     }
 }
Beispiel #20
0
 void DeathRPC(bool life, PhotonMessageInfo pmi)
 {
     if (life)
     {
         PlayersManager.FindPlayer(pmi.sender).score = PlayersManager.FindPlayer(pmi.sender).score / 7;
         Instantiate(explosion, body.transform.position, body.transform.rotation);
         tankStore.stan.SetActive(false);
         body.material = deathMat;
         head.material = deathMat;
         PlayersManager.FindPlayer(pmi.sender).gameObject.GetComponent <TankEvolution>().HullGameObject.tag = TagsManager.GetTag(Tag.StaticGameObject);
     }
     else
     {
         tankStore.stan.SetActive(true);
         body.material = defaultMat;
         head.material = defaultMat;
         PlayerSetup ps = PlayersManager.FindPlayer(pmi.sender).gameObject.GetComponent <PlayerSetup>();
         GameObject  myColliderObject = GetComponent <TankEvolution>().HullGameObject;
         if (ps.photonView.isMine)
         {
             TagsManager.SetGameObjectTag(myColliderObject, Tag.LocalPlayerBody);
             LayerManager.SetGameObjectLayer(myColliderObject, Layer.LocalPlayer);
         }
         else
         {
             TagsManager.SetGameObjectTag(myColliderObject, Tag.RemotePlayerBody);
             LayerManager.SetGameObjectLayer(myColliderObject, Layer.RemotePlayer);
         }
     }
 }
Beispiel #21
0
    public void SpawnPlayer()
    {
        GameObject myPlayerGO = PhotonNetwork.Instantiate("Player", GameManager.Instance.GetRandomGameObject(TagsManager.GetTag(Tag.PlayerSpawn)).transform.position,
                                                          GameManager.Instance.GetRandomGameObject(TagsManager.GetTag(Tag.PlayerSpawn)).transform.rotation, 0);

        UpdateMyPlayer(myPlayerGO.GetComponent <PhotonView>().viewID);
    }
Beispiel #22
0
    //Jestem pociskiem
    //O to mój krutki żywot:
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (own == null)
        {
            Debug.LogWarning("Nieznaleziono właściciela pocisku!");
            Destroy(gameObject);
            return;
        }
        //Jeśli wystrzelił mnie nie lokalny gracz..
        if (own.gameObject.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
        {
            //i trafiłem lokalnego gracza...
            if (coll.tag == TagsManager.GetTag(Tag.LocalPlayerBody))
            {
                //to lokalny gracz potrząsa swoją kamerą
                coll.GetComponent <TankObject>().PlayerGO.GetComponent <TankDeath>().tankCamera.GetComponent <Shake>().CamShake();
                //i robię BOOM!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }

            //aczkolwiek mogłem trafić w ogóle innego gracza (nie siebie)
            if (coll.tag == TagsManager.GetTag(Tag.RemotePlayerBody) && coll.gameObject != own)
            {
                //więc zrobię BOOM!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }

            //lub trafiłem Bota...
            if (coll.tag == TagsManager.GetTag(Tag.Bot))
            {
                //więc robię BOOM!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }
        }


        //Jeśli wystrzelił mnie lokalny gracz...
        else if (own.gameObject.tag == TagsManager.GetTag(Tag.LocalPlayerBody))
        {
            //own.GetComponent<GameOver>().tankCamera.GetComponent<Shake>().CamShake();

            //i trafiłem nie lokalnego gracza...
            if (coll.tag == TagsManager.GetTag(Tag.RemotePlayerBody))
            {
                //więc robię BOOM!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }

            //lub trafiłem Bota...
            if (coll.tag == TagsManager.GetTag(Tag.Bot))
            {
                //więc robię BOOM!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }
        }


        //Jeśli wystrzelił mnie BOT...
        else if (own.gameObject.tag == TagsManager.GetTag(Tag.Bot))
        {
            //i trafiłem jakiegoś gracza...
            if (coll.tag == TagsManager.GetTag(Tag.RemotePlayerBody) || coll.tag == TagsManager.GetTag(Tag.LocalPlayerBody))
            {
                //jeśli tak lokalny gracz potrząsa swoją kamerą
                coll.GetComponent <TankObject>().PlayerGO.GetComponent <TankDeath>().tankCamera.GetComponent <Shake>().CamShake();
                //i zrobi boom!
                Instantiate(Explosion, boom.position, transform.rotation);
                Destroy(gameObject);
            }
        }


        //Nie ważnie kto mnie wystrzelił
        //ale trafiłem chyba w kamień, a może to dom?...
        if (coll.tag == TagsManager.GetTag(Tag.StaticGameObject))
        {
            //więc robię BOOM!
            Instantiate(Explosion, boom.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Beispiel #23
0
    /// <summary>
    /// Looks for player respawns and moves the player in a random of them
    /// </summary>
    void UstawPozycje()
    {
        Vector3 pos = GameManager.Instance.GetRandomGameObject(TagsManager.GetTag(Tag.PlayerSpawn)).transform.position;

        GetComponent <TankEvolution>().TankGameObject.transform.position = pos;
    }