Beispiel #1
0
    public void RpcDestoryPowerupBox(string BoxObjectName, string PUName, float Delay)
    {
        ExploadScript ES = GameObject.Find(BoxObjectName).GetComponent <ExploadScript>();

        if (gameSession.roundType != "Armor")
        {
            ES.SpawnPowerup(PUName);
        }
        ES.SelfDestructionDelay = Delay;
        ES.SelfDestruction      = true;
    }
Beispiel #2
0
    public void ShootRaycast()
    {
        shotsCounter++;
        if (AimLineCollider)
        {
            AimLineCollider.enabled = false;
        }
        RaycastHit2D hit = Physics2D.Raycast(AimLine.position, AimLine.right * -50);

        if (hit.collider != null && gameSession.roundType == "PowerUp")
        {
            if (hit.collider.name != "ArmorPowerup" && hit.collider.name != "ArmorPowerup2" && hit.collider.name != "RandomPowerup")
            {
                powerUp            = new PowerUps();
                PowerupImage.color = new Color(0f, 0f, 0f, 0f);
                if (isServer)
                {
                    RpcResetPowerups();
                }
                else
                {
                    CmdResetPowerups();
                }
            }
        }
        else if (hit.collider == null && gameSession.roundType == "PowerUp")
        {
            powerUp            = new PowerUps();
            PowerupImage.color = new Color(0f, 0f, 0f, 0f);
            if (isServer)
            {
                RpcResetPowerups();
            }
            else
            {
                CmdResetPowerups();
            }
        }

        if (hit.collider != null)
        {
            //Distance = hit.distance;
            if (hit.collider.name != "Ground")
            {
                int    HitPoint = 0;
                string ShotType = "";
                if (hit.collider.name == "Head")
                {
                    HitPoint = 100;
                    ShotType = "HS";
                }
                else if (hit.collider.name == "Body")
                {
                    HitPoint = 45;
                    ShotType = "BS";
                }
                else if (hit.collider.name == "RightTopLeg")
                {
                    HitPoint = 20;
                    ShotType = "LS";
                }
                else if (hit.collider.name == "ArmorPowerup" || hit.collider.name == "ArmorPowerup2" || hit.collider.name == "RandomPowerup")
                {
                    HitPoint = 0;
                    ShotType = "PowerUp";
                }

                if (powerUp == PowerUps.DoubleHitPoint)
                {
                    HitPoint *= 2;
                }
                else if (powerUp == PowerUps.DoubleShot)
                {
                    HitPoint = Mathf.Abs(HitPoint - (HitPoint / 3));
                }
                else if (powerUp == PowerUps.InstantKill)
                {
                    HitPoint = 500;
                }

                if (hit.collider.name == "Hat")
                {
                    HitPoint = 0;
                    ShotType = "HatShot";
                }

                if (ShotType != "HatShot" && ShotType != "PowerUp")
                {
                    StartCoroutine(SpawnBlood((hit.distance / BulletScript.velocity), ShooterPlayerIndexV, hit.point.x, hit.point.y));
                }

                if (gameSession.roundType == "Kill")
                {
                    CmdUpdateHealth(HitPoint, int.Parse(hit.transform.name.Replace("Player", "")), ShotType, (hit.distance / BulletScript.velocity));
                    StartCoroutine(CheckHealth2(int.Parse(hit.transform.name.Replace("Player", ""))));
                }
                else if (gameSession.roundType == "Armor" || gameSession.roundType == "PowerUp")
                {
                    if (ShotType == "PowerUp")
                    {
                        ExploadScript ES = hit.collider.gameObject.GetComponent <ExploadScript>();
                        if (ES.SelfDestruction == false)
                        {
                            int x = 0;
                            if (RoundsCounter >= 10)
                            {
                                x = 6;
                            }
                            else
                            {
                                x = 5;
                            }

                            powerUp = (PowerUps)Random.Range(1, x);
                            //powerUp = (PowerUps)Random.Range(4, 5);
                            if (gameSession.roundType == "Armor")
                            {
                                powerUp = PowerUps.Armor;
                                CmdGetPowerUp(PowerUps.Armor);
                            }
                            else
                            {
                                CmdGetPowerUp(powerUp);
                            }

                            if (gameSession.roundType != "Armor")
                            {
                                ES.SpawnPowerup(powerUp.ToString());
                            }
                            ES.SelfDestructionDelay = (hit.distance / BulletScript.velocity);
                            ES.SelfDestruction      = true;

                            if (isServer)
                            {
                                RpcDestoryPowerupBox(hit.collider.name, powerUp.ToString(), (hit.distance / BulletScript.velocity));
                            }
                            else
                            {
                                CmdDestoryPowerupBox(hit.collider.name, powerUp.ToString(), (hit.distance / BulletScript.velocity));
                            }
                        }
                    }
                }
            }
            else
            {
                //didHitGround = true;
                if (isServer)
                {
                    RpcSpawnGroundEffect(hit.point.x, hit.point.y);
                }
                else
                {
                    CmdSpawnGroundEffect(hit.point.x, hit.point.y);
                }
            }
        }
        else
        {
            //Missed
        }
        if (AimLineCollider)
        {
            AimLineCollider.enabled = true;
        }

        if (powerUp == PowerUps.DoubleShot && gameSession.roundType == "Kill")
        {
            if (shotsCounter < 2)
            {
                GameObject.Find("AimLineController").GetComponent <Animator>().SetBool("AimLine", true);
                AimLineRotator.freeze = false;
                isAbleToShoot         = true;
            }
        }

        //NoTime Icon
        if (powerUp == PowerUps.DoubleShot && shotsCounter >= 2)
        {
            ShowNoTime = false;
        }
        else if (powerUp != PowerUps.DoubleShot)
        {
            ShowNoTime = false;
        }
    }