Ejemplo n.º 1
0
        public bool JoinGameHandler(int Game_Id, string Player_Name)
        {
            var game = HttpContext.Application["Game-" + Game_Id] as GameModel;

            if (game != null && game.Phase == 0)
            {
                var player = PlayerMethods.CreatePlayer(HttpContext.Session.SessionID, Game_Id, Player_Name);

                // Add the player Id to the game

                string player_Ids = game.Player_Ids;
                if (!(player_Ids ?? "").Contains(player.Id))
                {
                    player_Ids += "," + player.Id;
                }
                game.Player_Ids = player_Ids;
                HttpContext.Application["Game-" + game.Id] = game;

                player.Game_Id = game.Id;
                HttpContext.Application["Player-" + player.Id] = player;

                Session["Game_Id"] = game.Id;
                // new Hubs.GameHub().JoinGroup(game.Id.ToString());

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 public override void PostUpdateBuffs()
 {
     base.PostUpdateBuffs();
     if (immune == true)
     {
         player.controlJump    = false;
         player.controlDown    = false;
         player.controlLeft    = false;
         player.controlRight   = false;
         player.controlUp      = false;
         player.controlUseItem = false;
         player.controlUseTile = false;
         player.controlThrow   = false;
         player.gravDir        = 0f;
     }
     if (stunned == true)
     {
         player.controlJump    = false;
         player.controlDown    = false;
         player.controlLeft    = false;
         player.controlRight   = false;
         player.controlUp      = false;
         player.controlUseItem = false;
         player.controlUseTile = false;
         player.controlThrow   = false;
     }
     PlayerMethods.PostUpdateBuffs(player);
 }
Ejemplo n.º 3
0
    public void AddMessageToChat(byte gameAccess = 0, string senderName = "", byte senderTeam = 0, string senderMessage = "")
    {
        // The name of the player with the colors added
        string name = PlayerMethods.GetColoredTitleName(senderName, gameAccess, senderTeam);
        // The link you click on to get a player's rpofile
        string link = string.Format("<link=\"https://shakedown.gg/player/{0}/\">{1}</link>", senderName, name);
        // The constructed message
        string message = link + ": " + senderMessage;

        // Check if we're over our max messages
        // If we are, remove the first message
        if (MessageLabels.Count >= MaxMessages)
        {
            MessageLabels.RemoveAt(0);
        }

        // Create an empty gameobject for us to use as a variable
        ChatMessage label = null;

        // Instantiate it as a gameobject first, then get the KillFeedMessage component attached
        label = (Instantiate(MessagePrefab, MessageContentArea) as GameObject).GetComponent <ChatMessage>();

        // Set it as the last index in the transform
        // So that it's shown to the bottom of the UI
        label.transform.SetAsLastSibling();

        // Add the gameobject to our list
        MessageLabels.Add(label.GetComponent <TextMeshProUGUI>());

        // And now set the info on the text mesh
        label.Initialize(!IsOpen(), message);
        StartCoroutine(ScrollToBottom());
    }
Ejemplo n.º 4
0
        /// <summary>
        /// 窗体载入过程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmMain_Load(object sender, EventArgs e)
        {
            CE_ACTIVE_RESULT result = (CE_ACTIVE_RESULT)PlayerMethods.CEPlayer_Authorize(KEY);

            if (result != CE_ACTIVE_RESULT.SUCCESS)
            {
                HideAllViewer();
                if (result == CE_ACTIVE_RESULT.INVALID_KEY)
                {
                    MessageBox.Show("无效的激活密钥。。。");
                }
                else if (result == CE_ACTIVE_RESULT.INVALID_TIME)
                {
                    MessageBox.Show("该密钥有效时间已到期。。。");
                }
                else if (result == CE_ACTIVE_RESULT.INVALID_PROGRAM)
                {
                    MessageBox.Show("非本密钥对应的应用进程。。。");
                }
                else
                {
                    MessageBox.Show($"控件激活失败,代码:{(int)result}");
                }
                return;
            }
            SetLayout();
            mViewers[0].Url = Settings.Default.Url1;
            mViewers[1].Url = Settings.Default.Url2;
            mViewers[2].Url = Settings.Default.Url3;
            mViewers[3].Url = Settings.Default.Url4;
        }
Ejemplo n.º 5
0
    public void Init(PlayerNum owner, GameManager gameManager)
    {
        this.owner = owner;
        SetColor(PlayerMethods.GetPlayerColor(owner), gameManager);
        healthRemaining = startingHealth; // Need to do this here instead of start so that if someone hits us as we spawn we don't insta-die

        // Ugly hack - could be cleaned up
        if (owner == PlayerNum.One)
        {
            targetingLayerMask = PlayerMethods.allButP1;
            gameObject.layer   = LayerMask.NameToLayer("Pawn1");
        }
        else if (owner == PlayerNum.Two)
        {
            targetingLayerMask = PlayerMethods.allButP2;
            gameObject.layer   = LayerMask.NameToLayer("Pawn2");
        }
        else if (owner == PlayerNum.Three)
        {
            targetingLayerMask = PlayerMethods.allButP3;
            gameObject.layer   = LayerMask.NameToLayer("Pawn3");
        }
        else if (owner == PlayerNum.Four)
        {
            targetingLayerMask = PlayerMethods.allButP4;
            gameObject.layer   = LayerMask.NameToLayer("Pawn4");
        }

        _height = 100;
    }
Ejemplo n.º 6
0
    public void TakeDamage(int amount, Vector3 sourceLocation)
    {
        healthRemaining -= amount;
        ParticleSystem blood = Instantiate(bloodPS, transform.position, Quaternion.LookRotation(transform.up)).GetComponent <ParticleSystem>();

        blood.startColor = PlayerMethods.GetPlayerColor(owner);
        if (healthRemaining < 0)
        {
            for (int i = 0; i < 2; i++)
            {
                blood            = Instantiate(bloodPS, transform.position, Quaternion.LookRotation(transform.up)).GetComponent <ParticleSystem>();
                blood.startColor = PlayerMethods.GetPlayerColor(owner);
                blood.gameObject.transform.localScale *= 2;

                AudioSource source = blood.GetComponent <AudioSource>();
                source.pitch = Random.Range(2f, 2.5f);
                source.Play();
            }

            GameObject guts = Instantiate(ragdollPrefab, transform.position, Random.rotation);
            guts.GetComponentInChildren <Renderer>().sharedMaterial = GetComponentInChildren <Renderer>().sharedMaterial;
            Vector3 planetToPawn = (transform.position - planet.transform.position).normalized;
            Vector3 sourceToPawn = (transform.position - sourceLocation).normalized;
            guts.GetComponent <Rigidbody>().velocity        = planetToPawn * 15 + sourceToPawn * 20 + Random.onUnitSphere * 2;
            guts.GetComponent <Rigidbody>().angularVelocity = Random.onUnitSphere * 3;

            Destroy(gameObject);
        }
        else
        {
            audioSource.pitch = Random.Range(2f, 2.5f);
            audioSource.Play();
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (!GameManager.playing)
        {
            selectedPawns.Clear();
            UpdateSelector(Vector2.zero, Vector2.zero);
            return;
        }

        if (selectedPawns.Count == 0)
        {
            if (Input.GetMouseButtonDown(LEFT_CLICK))
            {
                startPoint = Input.mousePosition;
            }
            else if (Input.GetMouseButtonUp(LEFT_CLICK) && startPoint != Vector2.zero)
            {
                SelectUnitsV2(startPoint, Input.mousePosition);
                startPoint = Vector2.zero;
                UpdateSelector(Vector2.zero, Vector2.zero);
            }
            else if (startPoint != Vector2.zero)
            {
                UpdateSelector(startPoint, Input.mousePosition);
            }
        }
        else if (Input.GetMouseButtonDown(LEFT_CLICK))
        {
            Vector3    targetPosition;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, planetMask))
            {
                targetPosition = hit.point;
            }
            else
            {
                targetPosition  = Camera.main.ScreenToWorldPoint(Input.mousePosition + Vector3.forward * Vector3.Distance(transform.position, planet.transform.position));
                targetPosition += planet.toSurface(targetPosition);
            }
            int numAudio = 0;
            foreach (Pawn pawn in selectedPawns)
            {
                if (pawn != null)
                {
                    pawn.SetTargetPos(targetPosition);
                    pawn.SetColor(PlayerMethods.GetPlayerColor(pawn.owner), gameManager);
                    if (numAudio++ < 3)
                    {
                        pawn.PlayAudio(commandedClip);
                    }
                }
            }
            selectedPawns.Clear();
            Vector3 targetToPlanet = planet.transform.position - targetPosition;
            Instantiate(markerPrefab, targetPosition - targetToPlanet * 0.05f, Quaternion.LookRotation(Vector3.ProjectOnPlane(Vector3.one, targetToPlanet), targetToPlanet));
        }
    }
Ejemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     gameManager = FindObjectOfType <GameManager>();
     planet      = FindObjectOfType <Planet>();
     SnapToPlanet();
     GetComponent <Renderer>().material.color = PlayerMethods.GetPlayerColor(owningPlayer);
     pawnsInRange = new Dictionary <PlayerNum, HashSet <Pawn> >();
     audioSource  = GetComponent <AudioSource>();
 }
Ejemplo n.º 9
0
        private void Start()
        {
            User_Info info = DB_API.UserInfo;

            NamePlateText.SetText(PlayerMethods.GetColoredTitleName(info.Account.Name, (byte)info.Account.GameAccess, 0));
            StartCoroutine(DB_API.User_Avatar("m", callback =>
            {
                Avatar.sprite = Sprite.Create(callback, new Rect(0.0f, 0.0f, callback.width, callback.height), new Vector2(0.5f, 0.5f));
            }));

            InvokeRepeating("UpdateServerList", 0.0f, 3.0f);
        }
Ejemplo n.º 10
0
    // Mostly copied from Pawn
    public void SnapToPlanet()
    {
        planet = FindObjectOfType <Planet>(); // In case we hit this from the editor
        Vector3 toSurface = planet.toSurface(transform.position);

        transform.position += toSurface.normalized * (toSurface.magnitude - height);
        transform.rotation  = Quaternion.LookRotation(Vector3.ProjectOnPlane(Random.onUnitSphere, toSurface), -toSurface);
        Renderer renderer = GetComponent <Renderer>();

        renderer.sharedMaterial = mat; // Since we call this from the editor this stops us from creating instances of instances of instances.... of the material
        renderer.material.color = PlayerMethods.GetPlayerColor(owningPlayer);
    }
Ejemplo n.º 11
0
 public override void ResetEffects()
 {
     base.ResetEffects();
     chemicalDamage          = 1f;
     chemicalDamageMult      = 1f;
     player.armorPenetration = 0;
     magicDefense            = 0;
     armorJob       = 0;
     rogueBonus     = false;
     gellyfishArmor = false;
     stunned        = false;
     nightSet       = false;
     enInvis        = false;
     PlayerMethods.ResetEffects(player);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 窗口关闭时触发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmDVR_FormClosing(object sender, FormClosingEventArgs e)
 {
     // 异步委托关闭
     this.BeginInvoke(new Action(() =>
     {
         foreach (var tmpViewer in mViewers)
         {
             if (tmpViewer.IsPlaying)
             {
                 tmpViewer.StopPlay();
             }
         }
         // 释放资源
         PlayerMethods.CarEyePlayer_Release();
     }));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 窗口载入过程
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmDVR_Load(object sender, EventArgs e)
        {
            int tmpRes = PlayerMethods.CarEyePlayer_Init(GlobalCfg.DVRKey);

            for (int i = 0; i < MaxViewerCount; i++)
            {
                RTSPViewer tmpViewer = new RTSPViewer(this);
                tmpViewer.Click       += RTSPViewer_Click;
                tmpViewer.DoubleClick += RTSPViewer_DoubleClick;
                tmpViewer.Visible      = false;
                mViewers.Add(tmpViewer);
                this.pnlBase.Controls.Add(tmpViewer);
            }

            // 默认切换到全屏
            btnLayout_Click(btnFour, null);
        }
Ejemplo n.º 14
0
        public void Initialize(ModelBodyReferences bodyRef, int team)
        {
            BodyRef = bodyRef;
            Trail   = GetComponentInChildren <XftWeapon.XWeaponTrail>();

            PlayerMethods.SetTeamRenderers(GetComponentsInChildren <MeshRenderer>(), team);

            // Setup the animators fade duration here, just incase we didn't do it in the editor
            Animations.BasicMovement.FadeDuration  = 0.15f;
            Animations.BasicAirborne.FadeDuration  = 0.15f;
            Animations.StrafeMovement.FadeDuration = 0.15f;
            Animations.Airborne.FadeDuration       = 0.15f;
            // Setup the animators directional type here, just incase we didn't do it in the editor
            Animations.StrafeMovement.Type = Animancer.MixerState.Serializable2D.MixerType.Directional;
            Animations.Airborne.Type       = Animancer.MixerState.Serializable2D.MixerType.Directional;

            Holster();
        }
Ejemplo n.º 15
0
        public GameModel CreateGameHandler(string Player_Name)
        {
            var game = GameMethods.CreateGame();

            var player = PlayerMethods.CreatePlayer(HttpContext.Session.SessionID, game.Id, Player_Name);

            // Add the player Id to the game
            game.Player_Ids = "," + player.Id;
            HttpContext.Application["Game-" + game.Id] = game;

            player.Game_Id = game.Id;
            HttpContext.Application["Player-" + player.Id] = player;

            Session["Game_Id"] = game.Id;
            // new Hubs.GameHub().JoinGroup(game.Id.ToString());

            return(game);
        }
Ejemplo n.º 16
0
        private void BallStatusChanged(byte previousStatus, byte status)
        {
            // If neutral
            if (status == 0)
            {
                parented   = false;
                LocalOwner = null;
            }
            // If dropped
            else if (status == 1)
            {
                parented   = false;
                LocalOwner = null;
            }
            // If reset
            else if (status == 2)
            {
                parented   = false;
                LocalOwner = null;
            }
            // If touchdown
            else if (status == 3)
            {
                // Set the player's camera to the position of the player who touchdown
                Player.Networker.Instance.Controller.Camera.FollowPosition = LocalOwner.CameraPosition;

                //parented = false;
                //LocalOwner = null;

                parented = true;
                //LocalOwner = SpawnManager.GetPlayerObject(nv_BallOwner.Value).GetComponent<Player.Networker>().Controller;
                LocalOwner = PlayerMethods.GetPlayerObjectByOwnerID(nv_BallOwner.Value).GetComponent <Player.Networker>().Controller;
                ownerBallParentPosition = LocalOwner.BallParentPosition;
            }
            // If picked up
            else if (status == 4)
            {
                parented = true;
                //LocalOwner = SpawnManager.GetPlayerObject(nv_BallOwner.Value).GetComponent<Player.Networker>().Controller;
                LocalOwner = PlayerMethods.GetPlayerObjectByOwnerID(nv_BallOwner.Value).GetComponent <Player.Networker>().Controller;
                ownerBallParentPosition = LocalOwner.BallParentPosition;
            }
        }
Ejemplo n.º 17
0
        public void Message(string killerName, byte killerTeam, string victimName, byte victimTeam, byte weaponID)
        {
            // Check if we're over our max messages
            // If we are, remove the first message
            if (MessageLabels.Count >= MaxMessages)
            {
                MessageLabels.RemoveAt(0);
            }

            // Create an empty gameobject for us to use as a variable
            KillFeedMessage label = null;

            // Instantiate it as a gameobject first, then get the KillFeedMessage component attached
            label = (Instantiate(MessagePrefab, MessageContentArea) as GameObject).GetComponent <KillFeedMessage>();

            // Set it as the last index in the transform
            // So that it's shown to the bottom of the UI
            label.transform.SetAsLastSibling();

            // Add the gameobject to our list
            MessageLabels.Add(label.gameObject);

            // And now set the info
            string killer = PlayerMethods.GetColoredName(killerName, killerTeam);
            string victim = PlayerMethods.GetColoredName(victimName, victimTeam);
            Sprite icon   = null;

            if (killerName != victimName)
            {
                icon = Networker.Instance.Controller.GetWeaponByID(weaponID).ActiveSkin.Icon;
                label.Initialize(killer, victim, icon);
            }
            else
            {
                icon = SuicideIcon;
                label.Initialize("", victim, icon);
            }

            StartCoroutine(ScrollToBottom());
        }
Ejemplo n.º 18
0
        /// <summary>
        /// When a player confirms they are ready to proceed with the phase this fires, it checks if there are any other players we are waiting on, if not it proceeds with the round
        /// </summary>
        /// <param name="Game_Id"></param>
        public int ReadyHandler(int Game_Id, string Player_Id, int?Selected_Card_Id, string Selected_Target_Id, int Phase)
        {
            var game = HttpContext.Application["Game-" + Game_Id] as GameModel;

            // Assign the selected action to the player, and mark them as ready
            var currentPlayer = HttpContext.Application["Player-" + Player_Id] as PlayerModel;

            currentPlayer = PlayerMethods.ReadyPlayer(currentPlayer, Selected_Card_Id, Selected_Target_Id);
            HttpContext.Application["Player-" + currentPlayer.Id] = currentPlayer;

            // run through all the other players of the game and check their readiness
            string[] player_Ids     = game.Player_Ids.SplitAndTrim(',');
            int      PendingPlayers = 0;

            foreach (string id in player_Ids)
            {
                var player = HttpContext.Application["Player-" + id] as PlayerModel;
                if (!player.Ready)
                {
                    PendingPlayers++;
                }
            }
            // if there are no players still to go, begin the next phase
            if (PendingPlayers == 0)
            {
                switch (Phase)
                {
                case 1:
                    BeginPhase2Handler(Game_Id);
                    break;

                case 2:
                    BeginPhase3Handler(Game_Id);
                    break;
                }
            }

            return(PendingPlayers);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 播放指定通道音频
        /// </summary>
        /// <param name="aChannelId"></param>
        public void PlayChnSound(int aChannelId)
        {
            if (aChannelId <= 0)
            {
                return;
            }

            PlayerMethods.CarEyePlayer_PlaySound(aChannelId);

            foreach (var tmpItem in mViewers)
            {
                if (tmpItem.ChannelId == aChannelId)
                {
                    tmpItem.SetSoundStatus(true);
                    UpdateInfo("播放{0}的音频信号...", tmpItem.Token);
                }
                else
                {
                    tmpItem.SetSoundStatus();
                }
            }
        }
Ejemplo n.º 20
0
 public void SetUp()
 {
     _playerMethods = new PlayerMethods();
 }
Ejemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        _height -= Mathf.Abs(_height - height) * Time.deltaTime * 15;

        HandleAttacking();
        SnapToPlanet();

        Debug.DrawRay(transform.position + transform.up * 1.2f + transform.right, -transform.right * 2 * ((float)healthRemaining / startingHealth), PlayerMethods.GetPlayerColor(owner));
    }
Ejemplo n.º 22
0
        private void Update()
        {
            if (!IsOwner)
            {
                Vector3 aimPos = new Vector3(nv_AimPositionX.Value / 10, nv_AimPositionY.Value / 10, nv_AimPositionZ.Value / 10);
                Controller.AimTarget.position = aimPos;

                Controller.transform.position = Vector3.MoveTowards(Controller.transform.position, ReceivedPosition, 15 * Time.deltaTime);
                //Controller.transform.position = Vector3.Lerp(Controller.transform.position, ReceivedPosition, 10 * Time.deltaTime);
                Controller.transform.localEulerAngles = new Vector3(0, ReceivedPosition.w, 0);//Vector3.Lerp(Controller.transform.localEulerAngles, new Vector3(0, ReceivedPosition.w, 0), 25 * Time.deltaTime);

                Controller.SelectedWeapon = nv_SelectedWeapon.Value;

                // Update our animator
                Animator.HandleAnimations();

                // Set a variable to see if our camera can see the active player
                // We do this here so that we don't do this multiple times in different locations (causing more unnecessary calls)
                CanSeePlayer = PlayerMethods.CanSeeObject(Controller.Motor.Controller.bounds);
            }
            else
            {
                // Set our network object variables
                nv_Stamina.Value = (short)(Controller.State.Stamina * 100); // Keep in mind this is divided by 100

                b1.DrawingWeapon       = Controller.State.DrawingWeapon;
                b1.Aiming              = Controller.State.Aiming;
                nv_ChargedAmount.Value = (short)(Controller.State.ChargedAmount * 100); // Keep in mind this is divided by 100

                b1.Attacking          = Controller.State.Attacking;
                nv_AttackNumber.Value = Controller.State.AttackNumber;

                b1.Reloading            = Controller.State.Reloading;
                nv_SelectedWeapon.Value = Controller.State.SelectedWeapon;

                nv_Pitch.Value        = (short)(Controller.Input.Pitch * 100);
                nv_AimPositionX.Value = (short)(Controller.AimTarget.position.x * 10);
                nv_AimPositionY.Value = (short)(Controller.AimTarget.position.y * 10);
                nv_AimPositionZ.Value = (short)(Controller.AimTarget.position.z * 10);

                b1.IsGrounded  = Controller.Motor.State.IsGrounded;
                b1.IsSprinting = Controller.Motor.State.IsSprinting;
                b3.IsJumpDelay = Controller.Motor.State.IsJumpDelay;

                b1.IsDodging      = Controller.Motor.State.IsDodging;
                b1.DodgeDirection = Controller.Motor.State.DodgeDirection == 1;  // If our dodge direction is 1, we are dodging right ; else we are dodging left

                b2.IsWallSliding = Controller.Motor.State.IsWallSliding;
                //nv_WallHitNormalX.Value = (short)(Controller.Motor.State.WallHitNormal.x * 100);
                //nv_WallHitNormalZ.Value = (short)(Controller.Motor.State.WallHitNormal.z * 100);

                b2.IsWallJumpFrozen = Controller.Motor.State.IsWallJumpFrozen;
                b2.IsWallJumping    = Controller.Motor.State.IsWallJumping;

                b2.IsKnockingBack = Controller.Motor.State.IsKnockingBack;
                b2.IsWallSlammed  = Controller.Motor.State.IsWallSlammed;
                b2.IsPushingBack  = Controller.Motor.State.IsPushingBack;
                b2.IsFlinching    = Controller.Motor.State.IsFlinching;
                b2.IsStunned      = Controller.Motor.State.IsStunned;

                nv_Radius.Value     = (short)(Controller.Motor.Controller.radius * 1000); // Keep in mind this is divided by 1000
                nv_Collidable.Value = Controller.Motor.State.Collidable;

                if (Time.time - lastSentTime > (1f / PositionUpdatesPerSecond))
                {
                    Vector4 position = Controller.transform.position;
                    position.w = Controller.transform.localEulerAngles.y;

                    short moveDirX = (short)(Controller.Motor.State.MoveDirection.x * 1000);
                    short moveDirY = (short)(Controller.Motor.State.MoveDirection.y * 1000);
                    short moveDirZ = (short)(Controller.Motor.State.MoveDirection.z * 1000);

                    short moveSpeed = (short)(Controller.Motor.State.MoveSpeed * 1000);

                    // Set the bool arrays
                    bArray1 = new bool[8]
                    {
                        b1.DrawingWeapon,
                        b1.Aiming,
                        b1.Attacking,
                        b1.Reloading,
                        b1.IsGrounded,
                        b1.IsSprinting,
                        b1.IsDodging,
                        b1.DodgeDirection
                    };
                    bArray2 = new bool[8]
                    {
                        b2.IsWallSliding,
                        b2.IsWallJumpFrozen,
                        b2.IsWallJumping,
                        b2.IsKnockingBack,
                        b2.IsWallSlammed,
                        b2.IsPushingBack,
                        b2.IsFlinching,
                        b2.IsStunned
                    };
                    bArray3 = new bool[8]
                    {
                        b3.IsJumpDelay,
                        b3.fill_1,
                        b3.fill_2,
                        b3.fill_3,
                        b3.fill_4,
                        b3.fill_5,
                        b3.fill_6,
                        b3.fill_7,
                    };

                    InvokeServerRpc("Move_Server", position.x, position.y, position.z, position.w, moveDirX, moveDirY, moveDirZ, moveSpeed, ConvertBoolArrayToByte(bArray1), ConvertBoolArrayToByte(bArray2), ConvertBoolArrayToByte(bArray3), channel: "Unreliable");
                    lastSentTime = Time.time;
                }
            }
        }
Ejemplo n.º 23
0
 public void UpdateColors(int team)
 {
     Debug.Log("Set Team Color Renderers");
     PlayerMethods.SetTeamRenderers(FindObjectsOfType <MeshRenderer>(), team);
 }
Ejemplo n.º 24
0
    private void HandleCapturing()
    {
        Collider[] allPawns = Physics.OverlapSphere(transform.position, captureRange);

        // Partition the pawns by owner
        pawnsInRange.Clear();
        foreach (Collider coll in allPawns)
        {
            Pawn pawn = coll.GetComponent <Pawn>();
            if (pawn == null)
            {
                continue;
            }
            if (Vector3.Distance(pawn.transform.position, transform.position) > captureRange)
            {
                continue;
            }
            if (!pawnsInRange.ContainsKey(pawn.owner))
            {
                pawnsInRange.Add(pawn.owner, new HashSet <Pawn>());
            }
            pawnsInRange[pawn.owner].Add(pawn);
        }

        // If there's only one player in range they should be capturing the base.
        // Bases are captured by standing next to them for a period of time. If someone else has been attempting
        // capture, you have to let their capture time expire first
        if (pawnsInRange.Count == 0)   // No one at the point - capture time eroding
        {
            capturingTime -= Time.deltaTime;
        }
        else if (pawnsInRange.Count == 1)
        {
            var enumerator = pawnsInRange.Keys.GetEnumerator();
            enumerator.MoveNext();
            PlayerNum onlyPlayerInRange = enumerator.Current;
            if (onlyPlayerInRange == capturingPlayer)   // Player is continuing to capture the point
            {
                capturingTime += Time.deltaTime;
            }
            else if (onlyPlayerInRange != owningPlayer && capturingTime <= 0)     // Player is beginning to capture the point
            {
                capturingTime   = Time.deltaTime;
                capturingPlayer = onlyPlayerInRange;
                captureBar.GetComponent <Renderer>().material.color = PlayerMethods.GetPlayerColor(capturingPlayer);
            }
            else if (capturingPlayer != PlayerNum.Null)     // Capturing player is losing their progress
            {
                capturingTime -= Time.deltaTime;
            }
        }
        else     // Multiple players at the point - make sure the capturing player is one of them or they'll lose their capture progress
        {
            if (!pawnsInRange.ContainsKey(capturingPlayer))
            {
                capturingTime -= Time.deltaTime;
            }
        }

        if (capturingTime < 0)
        {
            capturingTime   = 0;
            capturingPlayer = PlayerNum.Null;
            captureBar.GetComponent <Renderer>().material.color = PlayerMethods.GetPlayerColor(capturingPlayer);
        }
        else if (capturingTime > captureTime)
        {
            for (int i = 0; i < 20; i++)
            {
                Vector3    random = Random.onUnitSphere * Random.Range(5f, 10f);
                GameObject guts   = Instantiate(gutsPrefab, transform.position + transform.up + random / 5, Random.rotation);
                guts.GetComponent <Renderer>().sharedMaterial = GetComponent <Renderer>().sharedMaterial;
                guts.GetComponent <Rigidbody>().velocity      = transform.up * 15 + random;
            }
            owningPlayer    = capturingPlayer;
            capturingPlayer = PlayerNum.Null;
            captureBar.GetComponent <Renderer>().sharedMaterial = gameManager.GetPlayerSharedMat(capturingPlayer);
            GetComponent <Renderer>().sharedMaterial            = gameManager.GetPlayerSharedMat(owningPlayer);
            capturingTime = 0;
            spawningTime  = 0;
            ParticleSystem capturePS = Instantiate(capturePSPrefab, transform.position, Quaternion.LookRotation(transform.up)).GetComponent <ParticleSystem>();
            capturePS.startColor = PlayerMethods.GetPlayerColor(owningPlayer);
        }

        Debug.DrawRay(transform.position - transform.forward * height, -transform.forward * (capturingTime / captureTime) * 3, PlayerMethods.GetPlayerColor(capturingPlayer));
        Debug.DrawRay(transform.position - transform.forward * height + transform.up * 0.1f, -transform.forward * 3, Color.black);
    }
Ejemplo n.º 25
0
 public Material GetPlayerSharedMat(PlayerNum playerNum)
 {
     return(GetPlayerSharedMat(PlayerMethods.GetPlayerColor(playerNum)));
 }