예제 #1
0
        public void ActivateSkill(int playerIndex, int skillPlace, int skillID, int targetID)
        {
            Skill skillInfos = gc.items[skillID].GetComponent <Skill>();

            skillType = skillInfos.type;
            switch ((SkillType)skillType)
            {
            case SkillType.QuietSound:
                gc.playersActions[playerIndex].isQuiet = true;
                break;

            case SkillType.StaffMaster:
                gc.playersActions[playerIndex].isDamageBoosted = true;
                break;

            case SkillType.Invisibility:
                gc.players[playerIndex].PlayerRenderer.enabled = false;
                break;

            case SkillType.Tazer:
                if (targetID != -1)
                {
                    gc.playersActions[targetID].isFallen       = true;
                    gc.playersActions[targetID].timeLeftFallen = 2.0f;
                    if (gc.playersActions[playerIndex].feetIsInWater || gc.playersActions[playerIndex].headIsInWater)
                    {
                        GameObject electricity = ObjectPooler.SharedInstance.GetPooledObject(12);
                        electricity.transform.position = gc.players[targetID].PlayerFeet.transform.position;
                        electricity.SetActive(true);
                        electricity.transform.parent        = Water.transform;
                        electricity.transform.localPosition = new Vector3(transform.localPosition.x, 0, transform.localPosition.z);
                    }
                }
                break;

            case SkillType.AquaticBreath:
                gc.playersActions[playerIndex].isAmphibian = true;
                break;

            case SkillType.Dash:
                if (PhotonNetwork.IsMasterClient)
                {
                    var forward = gc.players[playerIndex].PlayerModel.transform.forward;

                    forward.Normalize();

                    gc.players[playerIndex].PlayerChar.AddForce(forward * 250, ForceMode.Impulse);
                }
                //gc.players[playerIndex].PlayerChar.Move(gc.moveDirection[playerIndex]);
                if (gc.playersActions[playerIndex].isInWater || gc.playersActions[playerIndex].headIsInWater || gc.playersActions[playerIndex].isInWater)
                {
                    GameObject electricity = ObjectPooler.SharedInstance.GetPooledObject(12);
                    electricity.transform.position = gc.players[playerIndex].PlayerFeet.transform.position;
                    electricity.SetActive(true);
                    electricity.transform.parent = Water.transform;
                }
                break;

            case SkillType.IceWall:
                Vector3    pos = Vector3.forward;
                RaycastHit info;
                if (Physics.Raycast(gc.players[playerIndex].PlayerFeet.transform.position, Vector3.down, out info))
                {
                    pos = info.point + (Vector3.up * 1.5f) + (gc.players[playerIndex].PlayerCamera.transform.forward * 2);
                }

                GameObject iceWall = ObjectPooler.SharedInstance.GetPooledObject(22);
                iceWall.transform.position = pos;
                Vector3 rot = iceWall.transform.localEulerAngles;
                rot.y += gc.players[playerIndex].PlayerModel.transform.localEulerAngles.y;
                iceWall.transform.localEulerAngles = rot;
                iceWall.SetActive(true);

                IceWallScript iws = iceWall.GetComponent <IceWallScript>();
                iws.ActiveIceWall();
                iws.id = ec.iceWalls.Count;
                ec.iceWalls.Add(ec.iceWalls.Count, iceWall);
                break;

            case SkillType.Hunting:
                gc.playersActions[playerIndex].isHunting = true;
                break;

            default:
                break;
            }

            if (playerIndex == Array.IndexOf(gc.AvatarToUserId, PhotonNetwork.AuthValues.UserId))
            {
                if (!PhotonNetwork.IsMasterClient)
                {
                    ActiveSkillManager newSkill;
                    foreach (var skillManager in CurrentSkills)
                    {
                        if (skillManager.skillType == skillType && skillManager.skillID == skillID &&
                            skillManager.playerID == playerIndex)
                        {
                            if (skillManager.coolDown > 0)
                            {
                                return;
                            }

                            foundSkill = skillManager;
                        }
                    }
                    if (foundSkill)
                    {
                        newSkill   = foundSkill;
                        foundSkill = null;
                    }
                    else
                    {
                        newSkill = gameObject.AddComponent <ActiveSkillManager>();
                    }
                    //ActiveSkillManager newSkill = gameObject.AddComponent<ActiveSkillManager>();
                    newSkill.playerID   = playerIndex;
                    newSkill.bufftime   = skillInfos.bufftime;
                    newSkill.coolDown   = skillInfos.cooldown;
                    newSkill.skillType  = skillInfos.type;
                    newSkill.skillID    = skillID;
                    newSkill.skillPlace = skillPlace;
                    newSkill.isActive   = true;
                    CurrentSkills.Add(newSkill);
                }
                if (skillPlace == 0)
                {
                    if (skillInfos.type != (int)SkillType.Tazer && skillInfos.type != (int)SkillType.Dash && skillInfos.type != (int)SkillType.IceWall)
                    {
                        SkillBuff_0.GetComponent <RawImage>().texture = buffTextures[skillInfos.type].texture;
                        SkillBuffTime_0.GetComponent <Text>().text    = skillInfos.bufftime.ToString();
                    }
                }
                else
                {
                    if (skillInfos.type != (int)SkillType.Tazer && skillInfos.type != (int)SkillType.Dash && skillInfos.type != (int)SkillType.IceWall)
                    {
                        SkillBuff_1.GetComponent <RawImage>().texture = buffTextures[skillInfos.type].texture;
                        SkillBuffTime_1.GetComponent <Text>().text    = skillInfos.bufftime.ToString();
                    }
                }

                if (skillInfos.type == (int)SkillType.Hunting)
                {
                    TriggerBlock(true);
                }
            }
        }
예제 #2
0
        public void AskSkillActivation(int skillPlace, int playerIndex)
        {
            if (!PhotonNetwork.IsMasterClient)
            {
                return;
            }

            var        ray = gc.players[playerIndex].PlayerCamera.ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f));
            RaycastHit hitInfo;
            bool       touch    = Physics.Raycast(ray, out hitInfo, 2f);
            int        targetID = -1;

            if (touch)
            {
                if (hitInfo.transform.name.StartsWith("Player"))
                {
                    targetID = hitInfo.transform.gameObject.GetComponent <ExposerPlayer>().PlayerIndex;
                }
            }

            ActiveSkillManager newSkill;

            skillID = gc.players[playerIndex].PlayerInventory.skillInventory[skillPlace];
            if (skillID == -1)
            {
                return;
            }

            Skill skillInfos = gc.items[skillID].GetComponent <Skill>();

            skillType = skillInfos.type;

            foreach (var skillManager in CurrentSkills)
            {
                if (skillManager.skillType == skillType && skillManager.skillID == skillID &&
                    skillManager.playerID == playerIndex)
                {
                    if (skillManager.coolDown > 0)
                    {
                        return;
                    }

                    foundSkill = skillManager;
                }
            }

            if (foundSkill)
            {
                newSkill   = foundSkill;
                foundSkill = null;
            }
            else
            {
                newSkill = gameObject.AddComponent <ActiveSkillManager>();
            }

            newSkill.playerID   = playerIndex;
            newSkill.bufftime   = skillInfos.bufftime;
            newSkill.coolDown   = skillInfos.cooldown;
            newSkill.skillType  = skillInfos.type;
            newSkill.skillID    = skillID;
            newSkill.skillPlace = skillPlace;
            newSkill.isActive   = true;
            CurrentSkills.Add(newSkill);
            photonView.RPC("ActivateSkill", RpcTarget.All, playerIndex, skillPlace, skillID, targetID);
            //photonView.RPC("AnswerSkillActivation",RpcTarget.All,skillType, playerIndex);
        }