예제 #1
0
파일: Player.cs 프로젝트: Alan-Baylis/VOX
        public void RPCRespawn(int primaryWeaponID, int secondaryWeaponID, int meleeID, int item1ID, int item2ID)
        {
            if (photonView.isMine)
            {
                Destroy(cam.gameObject);
                Destroy(viewmodelRoot);

                PhotonNetwork.Destroy(gameObject);

                object[] data = new object[5];

                if (ServerController.gamemode == ServerController.Gamemode.GG)
                {
                    int     kills = ServerController.GetKills(PhotonNetwork.player);
                    GunInfo ggGun = ServerController.Instance.gunGameGuns[kills];

                    data[0] = ggGun.ID;
                    data[1] = -1;
                    data[2] = -1;
                    data[3] = -1;
                    data[4] = -1;
                }
                else
                {
                    data[0] = primaryWeaponID;
                    data[1] = secondaryWeaponID;
                    data[2] = meleeID;
                    data[3] = item1ID;
                    data[4] = item2ID;
                }

                Spawnpoint spawnpoint = MapController.FindSpawnpoint(PhotonNetwork.player.GetTeam());
                GameObject go         = PhotonNetwork.Instantiate("Player", spawnpoint.position, spawnpoint.rotation, 0, data);
            }
        }
예제 #2
0
        public void OnInitializeGamemode()
        {
            PhotonPlayer player = PhotonNetwork.player;

            ServerController.Gamemode gamemode = ServerController.gamemode;

            if (gamemode == ServerController.Gamemode.FFA)
            {
                player.SetTeam(PunTeams.Team.none);
                Open();
            }
            else if (gamemode == ServerController.Gamemode.TDM)
            {
                Open(false, true);
            }
            else if (gamemode == ServerController.Gamemode.OITC)
            {
                player.SetTeam(PunTeams.Team.none);
                SpawnPlayer(-1, 1, 8, -1, -1);
            }
            else if (gamemode == ServerController.Gamemode.GG)
            {
                player.SetTeam(PunTeams.Team.none);

                int     kills = ServerController.GetKills(player);
                GunInfo ggGun = ServerController.Instance.gunGameGuns[kills];

                SpawnPlayer(ggGun.ID, -1, 8, -1, -1);
            }
            else if (gamemode == ServerController.Gamemode.CTF)
            {
                Open(false, true);
            }
        }
예제 #3
0
파일: Player.cs 프로젝트: Alan-Baylis/VOX
        public void RPCDie(Vector3 velocity, Vector3 raycasterPosition, Vector3 raycasterForward, float physicsForce, int killerID, int killerWeaponID)
        {
            if (ServerController.HasRoundEnded)
            {
                return;
            }

            PhotonPlayer killer    = PhotonPlayer.Find(killerID);
            GunInfo      killerGun = GameController.GetGun(killerWeaponID);

            health = 0;

            worldModel.Die(velocity);

            bool headshot = false;

            RaycastHit hit;

            if (Physics.Raycast(raycasterPosition, raycasterForward, out hit, float.MaxValue, GameController.Instance.afterKillFireLayers))
            {
                if (hit.transform.gameObject.layer == 30)
                {
                    headshot = (hit.transform.tag == "Head") && !killerGun.disableHeadshots;

                    Rigidbody rigid = hit.collider.attachedRigidbody;
                    rigid.AddForceAtPosition(raycasterForward * physicsForce, hit.point, ForceMode.Impulse);
                }
            }


            ServerController.OnKill(killer, killerGun, photonView.owner, headshot);
        }
예제 #4
0
        public void UI_FinalSelect()
        {
            if (currentSelectMenu == SelectMenuType.Primary)
            {
                primary = currentSelected;
            }
            else if (currentSelectMenu == SelectMenuType.Secondary)
            {
                secondary = currentSelected;
            }
            else if (currentSelectMenu == SelectMenuType.Melee)
            {
                melee = currentSelected;
            }
            else if (currentSelectMenu == SelectMenuType.Item1)
            {
                item1 = currentSelected;
            }
            else
            {
                item2 = currentSelected;
            }

            UI_CloseSelectMenu();
        }
예제 #5
0
        public void Refresh(GunInfo newGunInfo)
        {
            if (newGunInfo != null)
            {
                info = newGunInfo;
            }

            Refresh();
        }
예제 #6
0
        public static void OnKill(PhotonPlayer killer, GunInfo gun, PhotonPlayer dead, bool headshot)
        {
            AddKill(killer);
            AddDeath(dead);

            if (onKill != null)
            {
                onKill(killer, gun, dead, headshot);
            }
        }
예제 #7
0
파일: Player.cs 프로젝트: Alan-Baylis/VOX
        public void OnKill(PhotonPlayer killer, GunInfo gun, PhotonPlayer dead, bool headshot)
        {
            bool isKiller = killer.ID == photonView.owner.ID;

            if (ServerController.gamemode == ServerController.Gamemode.OITC)
            {
                //OITC

                if (isKiller && photonView.isMine)
                {
                    ((Gun)items.secondary).ammo++;
                }
            }
            else if (ServerController.gamemode == ServerController.Gamemode.GG)
            {
                //GUNGAME

                GunInfo[] guns  = ServerController.Instance.gunGameGuns;
                int       kills = ServerController.GetKills(killer);

                if (kills < guns.Length)
                {
                    GunInfo newGun = guns[kills];

                    if (isKiller)
                    {
                        if (photonView.isMine)
                        {
                            if (items.primary != null)
                            {
                                Destroy(items.primary.gameObject);
                            }

                            items.primary = items.InstantiateGun(newGun.ID);
                        }

                        if (worldModel.primary != null)
                        {
                            Destroy(worldModel.primary.gameObject);
                        }

                        worldModel.primary = worldModel.InstantiateGun(newGun.ID);
                    }
                }
                else
                {
                    ServerController.Instance.EndRound();
                }
            }
        }
예제 #8
0
        public void OnKill(PhotonPlayer killer, GunInfo gun, PhotonPlayer dead, bool headshot)
        {
            KillfeedItem item = CreateKillfeedItem();

            item.Set(killer, gun, dead, headshot);

            if (PhotonNetwork.player == killer)
            {
                OnKill();
            }
            else if (PhotonNetwork.player == dead)
            {
                OnDie();
            }
        }
예제 #9
0
        public void Set(PhotonPlayer killer, GunInfo gun, PhotonPlayer dead, bool headshot)
        {
            killerText.gameObject.SetActive(true);
            weaponIcon.gameObject.SetActive(true);
            customReasonText.gameObject.SetActive(false);
            headshotIcon.SetActive(headshot);

            killerText.text  = killer.NickName;
            killerText.color = ServerController.GetObjectFromTeam <Color>(killer.GetTeam(), redTeamColor, blueTeamColor, noneTeamColor);

            float ratio = gun.sprite.rect.width / gun.sprite.rect.height;

            weaponIcon.sprite = gun.sprite;
            weaponLayoutElement.preferredWidth = weaponLayoutElement.preferredHeight * ratio;

            deadText.text  = dead.NickName;
            deadText.color = ServerController.GetObjectFromTeam <Color>(dead.GetTeam(), redTeamColor, blueTeamColor, noneTeamColor);
        }
예제 #10
0
        public void UI_OpenSelectMenu(int typeID)
        {
            SelectMenuType type = (SelectMenuType)Mathf.Clamp(typeID, 0, 4);

            GunInfo.GunType gunType = (GunInfo.GunType)Mathf.Clamp(typeID, 0, 3);

            currentSelectMenu = type;

            if (type == SelectMenuType.Primary)
            {
                currentSelected = primary;
            }
            else if (type == SelectMenuType.Secondary)
            {
                currentSelected = secondary;
            }
            else if (type == SelectMenuType.Melee)
            {
                currentSelected = melee;
            }
            else if (type == SelectMenuType.Item1)
            {
                currentSelected = item1;
            }
            else
            {
                currentSelected = item2;
            }

            for (int i = 0; i < items.Length; i++)
            {
                ClassItem classItem = items[i];
                classItem.gameObject.SetActive(classItem.info.type == gunType);
            }

            scrollRect.verticalNormalizedPosition = 1f;
            UpdateItems();

            main.SetActive(false);
            selectMenu.SetActive(true);
        }
예제 #11
0
        public GunBase InstantiateGun(int ID)
        {
            GunInfo    gunInfo = GameController.GetGun(ID);
            GameObject go      = Instantiate(gunInfo.viewmodel) as GameObject;

            go.name = string.Format("VM_{0}", gunInfo.Name);

            go.transform.SetParent(mainGunsScript.transform, false);
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;

            GunBase gun = go.GetComponent <GunBase>();

            gun.info = gunInfo;
            gun.main = mainGunsScript;

            CharacterCustomization customization = go.GetComponent <CharacterCustomization>();

            customization.StartUp();

            return(gun);
        }
예제 #12
0
        void Start()
        {
            UpdateItems();
            OnInitializeGamemode();

            GunInfo[] allGuns = GameController.GetAllGuns();
            items = new ClassItem[allGuns.Length];

            for (int i = 0; i < allGuns.Length; i++)
            {
                GunInfo gun = allGuns[i];

                GameObject go = Instantiate(classItemPrefab) as GameObject;
                go.transform.SetParent(classItemParent);
                go.transform.localScale = Vector3.one;

                ClassItem classItem = go.GetComponent <ClassItem>();
                classItem.Refresh(gun);
                classItem.classCreation = this;

                items[i] = classItem;
            }
        }
예제 #13
0
        public WorldModelGun InstantiateGun(int ID)
        {
            GunInfo    gunInfo = GameController.GetGun(ID);
            GameObject go      = Instantiate(gunInfo.worldmodel) as GameObject;

            go.name = string.Format("WM_{0}", gunInfo.Name);

            go.transform.SetParent(gunsParent.transform, false);
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
            go.transform.localScale    = Vector3.one;

            WorldModelGun gun = go.GetComponent <WorldModelGun>();

            gun.info = gunInfo;
            gun.leftArmCharacterJoint.connectedBody  = torsoRigidbody;
            gun.rightArmCharacterJoint.connectedBody = torsoRigidbody;

            CharacterCustomization customization = go.GetComponent <CharacterCustomization>();

            customization.StartUp();

            return(gun);
        }
예제 #14
0
        void Update()
        {
            if (!chatField.gameObject.activeInHierarchy)
            {
                if (!classCreation.classes.activeInHierarchy)
                {
                    if (!menu.activeInHierarchy)
                    {
                        if (Input.GetKeyDown(KeyCode.Escape))
                        {
                            menu.SetActive(true);
                        }
                        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
                        {
                            chatField.gameObject.SetActive(true);
                        }
                    }
                    else
                    {
                        if (Input.GetKeyDown(KeyCode.Escape))
                        {
                            UI_Resume();
                        }
                    }
                }
                else
                {
                    UI_Resume();
                }
            }
            else
            {
                if (!chatField.isFocused)
                {
                    chatField.Select();
                    chatField.ActivateInputField();
                }

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    chatField.text = "";
                    chatField.gameObject.SetActive(false);
                }

                if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
                {
                    if (chatField.text != "")
                    {
                        SendChatMessage(chatField.text);
                    }

                    chatField.text = "";
                    chatField.gameObject.SetActive(false);
                }
            }

            scoreboard.scoreboard.SetActive((Input.GetKey(KeyCode.Tab) && !GameController.IsPaused()) || (ServerController.HasRoundEnded && !menu.activeSelf));

            float time    = (float)ServerController.RemainingTime;
            int   minutes = Mathf.FloorToInt(time / 60);
            int   seconds = Mathf.FloorToInt(time % 60);

            timerText.text = string.Format("{0}:{1:00}", minutes, seconds);

            hitCG.alpha          = Mathf.Lerp(hitCG.alpha, 0f, hitLerpSpeed * Time.deltaTime);
            crosshairImage.color = Color.Lerp(crosshairImage.color, Color.white, hitmarkerLerpSpeed * Time.deltaTime);

            Player player = ServerController.player;

            if (player != null)
            {
                GunBase currentGunBase = player.items.currentGun;
                if (currentGunBase != null)
                {
                    GunInfo currentGunInfo = currentGunBase.info;

                    bool isCrosshairHidden = player.isDead || (currentGunInfo.hideCrosshair && !player.reloading);
                    bool hidingCrosshair   = player.aiming;

                    if (currentGunBase is Grenade)
                    {
                        Grenade currentGrenade = (Grenade)currentGunBase;
                        hidingCrosshair = currentGrenade.throwing;
                    }

                    float targetCrosshairAlpha = hidingCrosshair ? (currentGunInfo.showCrosshairWhileAiming ? 1f : 0f) : (isCrosshairHidden ? 0f : 1f);

                    float multiplier = 1f;

                    if (hidingCrosshair)
                    {
                        multiplier = 0f;
                    }
                    else if (player.running)
                    {
                        multiplier = currentGunInfo.runningMultiplier;
                    }
                    else if (player.crouching)
                    {
                        multiplier = currentGunInfo.crouchingMultiplier;
                    }
                    else
                    {
                        multiplier = 1f;
                    }

                    Vector2 targetCrosshairSize = Vector2.one * (currentGunInfo.defaultCrosshairSize * multiplier);

                    crosshairCP.alpha   = Mathf.Lerp(crosshairCP.alpha, targetCrosshairAlpha, Gun.aimingLerpSpeed * Time.deltaTime);
                    crosshair.sizeDelta = Vector2.Lerp(crosshair.sizeDelta, targetCrosshairSize, crosshairSizeLerpSpeed * Time.deltaTime);

                    if (currentGunBase is Gun)
                    {
                        Gun currentGun = currentGunBase as Gun;

                        ammoText.gameObject.SetActive(true);

                        if (currentGun.maxAmmo >= 0)
                        {
                            ammoText.text = string.Format("{0}/{1}", currentGun.ammo, currentGun.maxAmmo);
                        }
                        else
                        {
                            ammoText.text = currentGun.ammo.ToString();
                        }

                        if (player.reloading)
                        {
                            float value = Mathf.InverseLerp(currentGun.reloadingT, currentGun.reloadingT + currentGunInfo.reloadTime, Time.time);
                            crosshairCP.transform.localEulerAngles = Vector3.Lerp(Vector3.zero, Vector3.forward * 90f, value);
                            crosshairCP.transform.localScale       = Vector3.one;
                        }
                    }
                    else if (currentGunBase is Grenade)
                    {
                        Grenade currentGrenade = currentGunBase as Grenade;

                        ammoText.gameObject.SetActive(true);
                        ammoText.text = currentGrenade.grenades.ToString();
                    }
                    else if (currentGunBase is Knife)
                    {
                        ammoText.gameObject.SetActive(false);
                    }

                    healthBarMask.localScale = new Vector3(Mathf.Clamp01((float)player.health / 100f), 1f, 1f);

                    if (healthBarMask.localScale.x > 0f)
                    {
                        healthBar.localScale = new Vector3(1f / healthBarMask.localScale.x, 1f, 1f);
                    }
                }
            }
        }
예제 #15
0
 public void Select(GunInfo info)
 {
     currentSelected = info;
     UpdateItems();
 }