Example #1
0
        void LateUpdate()
        {
            bool isAlone = true;
            BombersPlayerController tempController;

            BombersPlayerController[]      playerList;
            List <BombersPlayerController> playerListList = new List <BombersPlayerController>();

            foreach (LobbyMemberInfo member in BombersNetworkManager.LobbyInfo.Members)
            {
                tempController = member.PlayerController;
                playerListList.Add(member.PlayerController);
            }

            int count = 0;

            while (count < playerListList.Count)
            {
                if (playerListList[count] != null &&
                    playerListList[count].m_team == 0)
                {
                    playerListList.RemoveAt(count);
                }
                else
                {
                    count++;
                }
            }
            playerList = playerListList.ToArray();
            {
                if (playerList.Length > 1)
                {
                    isAlone = false;
                }
            }
            if (isAlone && m_bombs == 0 && m_aloneBombTimer >= 3)
            {
                m_aloneBombTimer = 0;
                AddBomb();
            }

            if (m_bombs > 0 && m_playerPlane != null)
            {
                m_targetingReticule.transform.Find("TargetSprite").GetComponent <SpriteRenderer>().color =
                    Color.Lerp(m_targetingReticule.transform.Find("TargetSprite").GetComponent <SpriteRenderer>().color, new Color(1, 1, 1, m_playerPlane.IsLocalPlayer ? 0.3f : 0.0f), 4 * Time.deltaTime);

                m_targetingReticule.GetComponent <MeshRenderer>().enabled = m_playerPlane.IsLocalPlayer;
                Vector3 position      = m_playerPlane.transform.position;
                Vector3 planeVelocity = m_playerPlane.GetComponent <Rigidbody>().velocity;
                Vector3 velocity      = planeVelocity;
                count = 1;
                Vector3 lastPos   = m_playerPlane.transform.position;
                int     layerMask = (1 << 16) | (1 << 17) | (1 << 4) | (1 << 20);
                bool    hitFound  = false;
                while (!hitFound)
                {
                    velocity += Physics.gravity * 0.01f;
                    velocity  = velocity * 1 / (1 + 0.01f * 0.8f);
                    position += velocity * 0.01f;

                    if (position.z > 10 * count)
                    {
                        count++;
                        RaycastHit hit = new RaycastHit();
                        if (Physics.SphereCast(lastPos, 10.4f, position - lastPos, out hit, (position - lastPos).magnitude, layerMask))
                        {
                            hitFound = true;

                            position    = lastPos + ((position - lastPos).normalized * ((hit.point.z - lastPos.z) / (position.z - lastPos.z)));
                            position.z += 5;
                            position.z -= 0.5f;
                        }

                        lastPos = position;
                    }
                    else if (position.y > 3000.0f || position.y < -3000.0f || position.z >= 121.5f)
                    {
                        hitFound   = true;
                        position.z = 121.5f;
                    }
                }

                m_targetingReticule.transform.position = position;
                TextMesh bombCounter = m_targetingReticule.transform.Find("BombCounter").GetComponent <TextMesh>();
                int      maxBombs    = GConfigManager.GetIntValue("MaxBombCapacity");
                if (m_bombs == 0 || m_bombs == 1 || !m_playerPlane.IsLocalPlayer)
                {
                    bombCounter.text = "";
                }
                else if (m_bombs < maxBombs)
                {
                    bombCounter.color = new Color(1, 1, 1, 0.8f);
                    bombCounter.text  = m_bombs.ToString();
                }
                else
                {
                    bombCounter.color = new Color(1, 0.4f, 0.4f, 0.8f);
                    bombCounter.text  = m_bombs.ToString();
                }
            }
            else
            {
                m_targetingReticule.GetComponent <MeshRenderer>().enabled = false;
                m_targetingReticule.transform.Find("TargetSprite").GetComponent <SpriteRenderer>().color = Color.Lerp(m_targetingReticule.transform.Find("TargetSprite").GetComponent <SpriteRenderer>().color, new Color(1, 1, 1, 0), 4 * Time.deltaTime);
                m_targetingReticule.transform.Find("BombCounter").GetComponent <TextMesh>().text         = "";
            }
        }
        public void ActivatePlane()
        {
            m_playerPlane.GetComponent <PlaneController>().enabled = true;
            m_playerPlane.transform.GetChild(0).gameObject.SetActive(true);
            m_playerPlane.transform.GetChild(1).gameObject.SetActive(true);
            AudioSource audioSrc = m_playerPlane.GetComponent <AudioSource>();

            if (!audioSrc.isPlaying)
            {
                audioSrc.clip = m_engineSnd;
                audioSrc.Play();
            }
            m_playerPlane.GetComponent <Collider>().enabled = true;
        }