Beispiel #1
0
        void Start()
        {
            m_lastPositions = new PlaneVector[1];
            m_planeDamage   = new List <GameObject>()
            {
                null, null, null, null
            };
            Debug.Log(m_playerID);
            transform.FindChild("NameTag").gameObject.GetComponent <TextMesh>().text = BombersPlayerController.GetPlayer(m_playerID).m_displayName;
            if (BombersPlayerController.GetPlayer(m_playerID).isLocalPlayer) //isLocal
            {
                transform.FindChild("NameTag").gameObject.GetComponent <TextMesh>().text = "";
            }
            m_planeBank = transform.FindChild("PlaneBank");
            for (int i = 0; i < m_lastPositions.Length; i++)
            {
                m_lastPositions[i] = new PlaneVector(transform.position, transform.up);
            }

            string teamBomberPath = "";

            if (BombersPlayerController.GetPlayer(m_playerID).m_team == 1)
            {
                teamBomberPath   = "Bomber01";
                gameObject.layer = 8;
                transform.FindChild("NameTag").gameObject.GetComponent <TextMesh>().color = Color.green;
            }
            else
            {
                teamBomberPath   = "Bomber02";
                gameObject.layer = 9;
                transform.FindChild("NameTag").gameObject.GetComponent <TextMesh>().color = Color.red;
            }
            Transform  graphicPivot = transform.FindChild("PlaneBank").FindChild("PlaneGraphic");
            GameObject graphic      = (GameObject)Instantiate((GameObject)Resources.Load(teamBomberPath), graphicPivot.position, graphicPivot.rotation);

            graphic.transform.parent        = graphicPivot;
            graphic.transform.localPosition = Vector3.zero;
            graphic.transform.localRotation = Quaternion.identity;

            m_bulletSpawnPoint = graphic.transform.FindChild("BulletSpawn");
            m_leftContrail     = graphic.transform.FindChild("LeftSmokeTrail").GetComponent <ParticleSystem>();
            m_rightContrail    = graphic.transform.FindChild("RightSmokeTrail").GetComponent <ParticleSystem>();

            m_gunCharge = transform.GetChild(0).GetChild(0).FindChild("GunCharge").gameObject;
            m_gunCharge.GetComponent <Animator>().speed = 1 / GameObject.Find("BrainCloudStats").GetComponent <BrainCloudStats>().m_multiShotDelay;
        }
Beispiel #2
0
            public float AngleTo(PlaneVector aVector)
            {
                float direction = 1;
                float angle     = 0.0f;

                if ((m_direction.x * aVector.m_direction.y) - (m_direction.y * aVector.m_direction.x) < 0)
                {
                    direction = -1;
                }

                angle = Vector3.Angle(m_direction, aVector.m_direction);

                if (m_direction == aVector.m_direction)
                {
                    angle = 0;
                }

                return(angle * direction);
            }
Beispiel #3
0
        void FixedUpdate()
        {
            if (!isLocalPlayer)
            {
                return;
            }

            Vector3 direction = GetComponent <Rigidbody>().velocity;

            if (direction == Vector3.zero)
            {
                direction = transform.up;
            }
            else
            {
                direction.Normalize();
            }

            direction = transform.up;
            float angle = m_lastPositions[0].AngleTo(new PlaneVector(transform.position, direction)) * 5;

            if (angle > 90)
            {
                angle = 90;
            }
            else if (angle < -90)
            {
                angle = -90;
            }

            if (angle < 0)
            {
                m_isBankingRight = true;
                m_isBankingLeft  = false;
            }
            else if (angle > 0)
            {
                m_isBankingRight = false;
                m_isBankingLeft  = true;
            }
            else
            {
                m_isBankingRight = false;
                m_isBankingLeft  = false;
            }

            float targetAngle = 0;


            if (m_bankTime < 0)
            {
                targetAngle = -90 * m_bankCurve.Evaluate(m_bankTime / -m_timeToFullBank);
            }
            else
            {
                targetAngle = 90 * m_bankCurve.Evaluate(m_bankTime / m_timeToFullBank);
            }

            m_bankAngle = targetAngle;

            Vector3 eulerAngles = m_planeBank.localEulerAngles;

            eulerAngles.y = m_bankAngle;
            m_planeBank.localEulerAngles = eulerAngles;
            m_lastPositions[0]           = new PlaneVector(transform.position, direction);
        }
        override protected void Start()
        {
            m_velocityMaxMagnitude = GConfigManager.GetFloatValue("MaxAcceleration");
            _classType             = BombersNetworkManager.PLANE_CONTROLLER;
            m_lastPositions        = new PlaneVector[1];
            m_planeDamage          = new List <GameObject>()
            {
                null, null, null, null
            };
            TextMesh textMesh = transform.FindDeepChild("NameTag").gameObject.GetComponent <TextMesh>();

            PlayerController = BombersPlayerController.GetPlayer(PlayerId);

            // setup the member info
            if (PlayerController.MemberInfo == null)
            {
                PlayerController.MemberInfo = BombersNetworkManager.LobbyInfo.GetMemberWithProfileId(PlayerController.ProfileId);
            }

            textMesh.text = PlayerController.m_displayName;
            if (PlayerController.IsLocalPlayer)
            {
                textMesh.text = "";
            }
            m_planeBank = transform.FindDeepChild("PlaneBank");
            for (int i = 0; i < m_lastPositions.Length; i++)
            {
                m_lastPositions[i] = new PlaneVector(transform.position, transform.up);
            }

            string teamBomberPath = "";
            bool   bHasGoldWings  = false;

            if (PlayerController.MemberInfo.ExtraData.ContainsKey(GBomberRTTConfigManager.JSON_GOLD_WINGS))
            {
                bHasGoldWings = (bool)PlayerController.MemberInfo.ExtraData[GBomberRTTConfigManager.JSON_GOLD_WINGS];
            }

            if (PlayerController.m_team == 1)
            {
                teamBomberPath   = bHasGoldWings ? "Bomber01Golden" : "Bomber01";
                gameObject.layer = 8;
                textMesh.color   = Color.green;
            }
            else
            {
                teamBomberPath   = bHasGoldWings ? "Bomber02Golden" : "Bomber02";
                gameObject.layer = 9;
                textMesh.color   = Color.red;
            }

            SmartsComponent = PlayerController.transform.FindDeepChild("smartsComponent").gameObject;
            SmartsComponent.SetActive(true);
            SmartsComponent.layer = PlayerController.m_team == 1 ? 21 : 22; // debug collisions

            Transform  graphicPivot = transform.FindDeepChild("PlaneGraphic");
            GameObject graphic      = (GameObject)Instantiate((GameObject)Resources.Load("Prefabs/Game/" + teamBomberPath), graphicPivot.position, graphicPivot.rotation);

            graphic.transform.parent        = graphicPivot;
            graphic.transform.localPosition = Vector3.zero;
            graphic.transform.localRotation = Quaternion.identity;

            m_bulletSpawnPoint = graphic.transform.FindDeepChild("BulletSpawn");
            m_leftContrail     = graphic.transform.FindDeepChild("LeftSmokeTrail").GetComponent <ParticleSystem>();
            m_rightContrail    = graphic.transform.FindDeepChild("RightSmokeTrail").GetComponent <ParticleSystem>();

            m_gunCharge = transform.FindDeepChild("GunCharge").gameObject;
            m_gunCharge.GetComponent <Animator>().speed = 1 / GConfigManager.GetFloatValue("MultishotDelay");
            if (!PlayerController.IsLocalPlayer)
            {
                m_gunCharge.transform.Find("ChargeReady").transform.GetComponent <AudioSource>().enabled = false;
            }

            transform.localPosition = Vector3.zero;
            m_rigidBody             = GetComponent <Rigidbody>();

            _syncTransformInformation = true;
            // no delay by default
            m_syncTransformationDelay = 0.0f;
            transform.position        = PlayerController.transform.position;

            if (IsServer)
            {
                SendStart(_classType, PlayerId, _fileName, transform);
            }

            base.Start();
        }