Beispiel #1
0
        /*
         * public void FireFlare(Vector3 aPosition, Vector3 aVelocity)
         * {
         *  float flareDelay = BrainCloudStats.Instance.m_flareCooldown;
         *  if ((Time.time - m_lastFlare) > flareDelay)
         *  {
         *      m_lastFlare = Time.time;
         *      GetComponent<BombersPlayerController>().FireFlareCommand(aPosition, aVelocity);
         *  }
         * }
         */

        public GameObject SpawnBomb(BombInfo aBombInfo)
        {
            m_bombs--;
            GameObject      player = null;
            PlaneController playerPlaneController = null;
            PlaneController tempPlaneController   = null;

            foreach (LobbyMemberInfo member in BombersNetworkManager.LobbyInfo.Members)
            {
                tempPlaneController = member.PlayerController.m_playerPlane;
                if (tempPlaneController.NetId == aBombInfo.m_shooter)
                {
                    player = member.PlayerController.gameObject;
                    playerPlaneController = tempPlaneController;
                    break;
                }
            }
            if (playerPlaneController != null)
            {
                GameObject flare = (GameObject)Instantiate(m_bombDropPrefab, player.transform.position, playerPlaneController.m_bulletSpawnPoint.rotation);
                flare.transform.parent = player.transform;
                if (aBombInfo.m_shooter == GetComponent <BombersPlayerController>().NetId)
                {
                    flare.GetComponent <AudioSource>().spatialBlend = 0;
                }
                flare.GetComponent <AudioSource>().Play();
            }

            GameObject bomb = (GameObject)Instantiate((BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team == 1) ? m_bombPrefab1 : m_bombPrefab2, aBombInfo.m_startPosition, Quaternion.LookRotation(aBombInfo.m_startDirection, -Vector3.forward));

            bomb.GetComponent <Rigidbody>().velocity      = aBombInfo.m_startVelocity;
            bomb.GetComponent <BombController>().BombInfo = aBombInfo;
            return(bomb);
        }
        public void LateInit(BombersPlayerController controller)
        {
            _playerController = controller;

            _fsm = StateMachine <ePlayerControllerAIStates> .Initialize(this);

            _fsm.ChangeState(ePlayerControllerAIStates.IDLE);
            _fsm.Changed += _fsm_Changed;
        }
        void OnTriggerExit(Collider aCollision)
        {
            BombersPlayerController planeController = aCollision.transform.parent.GetComponent <BombersPlayerController>();

            if (planeController != null)
            {
                onCollisionExit(aCollision, planeController.m_playerPlane);
            }
        }
        void OnCollisionEnter(Collision aCollision)
        {
            m_isActive = false;

            if (IsServer)
            {
                if (aCollision.gameObject.layer == 4)
                {
                    BombersNetworkManager.LocalPlayer.DeleteBombCommand(this, 0);
                }
                else if (aCollision.gameObject.layer == 20) //it hit a rock
                {
                    BombersNetworkManager.LocalPlayer.DeleteBombCommand(this, 1);
                }
                else //it hit a ship
                {
                    BombersPlayerController shooterController = BombersPlayerController.GetPlayer(BombInfo.m_shooter);
                    if ((shooterController.m_team == 1 && aCollision.gameObject.layer == 16) || (shooterController.m_team == 2 && aCollision.gameObject.layer == 17))
                    {
                        BombersNetworkManager.LocalPlayer.DeleteBombCommand(this, 2);
                    }
                    else
                    {
                        ShipController    controller  = aCollision.transform.parent.parent.parent.gameObject.GetComponent <ShipController>();
                        List <ShipTarget> shipTargets = controller.GetTargets();
                        for (int i = 0; i < shipTargets.Count; i++)
                        {
                            if ((transform.position - shipTargets[i].m_position.position).magnitude <= m_bombRadius + shipTargets[i].m_radius)
                            {
                                if (!shipTargets[i].m_isAlive)
                                {
                                    continue;
                                }
                                else
                                {
                                    shipTargets[i].m_isAlive = false;
                                    BombersNetworkManager.LocalPlayer.HitShipTargetPointCommand(shipTargets[i].m_shipID, shipTargets[i].m_index, m_bombInfo.GetJson());
                                }

                                if (!aCollision.transform.parent.parent.parent.gameObject.GetComponent <ShipController>().IsAlive())
                                {
                                    BombersNetworkManager.LocalPlayer.DestroyShipCommand(controller.m_shipID, m_bombInfo.GetJson());
                                    break;
                                }
                            }
                        }
                        BombersNetworkManager.LocalPlayer.DeleteBombCommand(this, 1);
                    }
                }
            }
        }
Beispiel #5
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;
        }
        void Update()
        {
            BombersPlayerController controller = null;

            for (int i = 0; i < BombersNetworkManager.LobbyInfo.Members.Count; ++i)
            {
                controller = BombersNetworkManager.LobbyInfo.Members[i].PlayerController;
                if (controller != null && controller.m_planeActive && controller.m_playerPlane != null &&
                    (controller.IsLocalPlayer || (controller.m_playerPlane.IsServerBot && controller.IsServer)))
                {
                    if (!GetComponent <Collider>().bounds.Contains(controller.m_playerPlane.transform.position))
                    {
                        controller.LeftBounds();
                    }
                    else
                    {
                        controller.EnteredBounds();
                    }
                }
            }
        }
        // pass in -1 for closest controller
        protected BombersPlayerController GetClosestControllerOnTeam(int in_team)
        {
            BombersPlayerController closestController = null;
            BombersPlayerController tempController    = null;
            Vector3 closestVector = Vector3.one * 99999999999999999.0f;
            Vector3 tempVector    = Vector3.one;
            Vector3 myPos         = transform.position;

            for (int i = 0; i < BombersNetworkManager.LobbyInfo.Members.Count; ++i)
            {
                tempController = BombersNetworkManager.LobbyInfo.Members[i].PlayerController;
                if (in_team < 0 || in_team == tempController.m_team)
                {
                    tempVector = myPos - tempController.m_playerPlane.transform.position;
                    if (tempVector.magnitude < closestVector.magnitude)
                    {
                        closestVector     = tempVector;
                        closestController = tempController;
                    }
                }
            }

            return(closestController);
        }
Beispiel #8
0
        void OnCollisionEnter(Collision aCollision)
        {
            m_isActive = false;

            if (isServer)
            {
                if (aCollision.gameObject.layer == 4)
                {
                    BombersNetworkManager.m_localPlayer.DeleteBombCommand(this, 0);
                }
                else if (aCollision.gameObject.layer == 20) //it hit a rock
                {
                    BombersNetworkManager.m_localPlayer.DeleteBombCommand(this, 1);
                }
                else //it hit a ship
                {
                    if ((BombersPlayerController.GetPlayer(m_bombInfo.m_shooter).m_team == 1 && aCollision.gameObject.layer == 16) || (BombersPlayerController.GetPlayer(m_bombInfo.m_shooter).m_team == 2 && aCollision.gameObject.layer == 17))
                    {
                        BombersNetworkManager.m_localPlayer.DeleteBombCommand(this, 2);
                    }
                    else
                    {
                        List <ShipController.ShipTarget> shipTargets = aCollision.transform.parent.parent.parent.gameObject.GetComponent <ShipController>().GetTargets();
                        for (int i = 0; i < shipTargets.Count; i++)
                        {
                            if ((transform.position - shipTargets[i].m_position.position).magnitude <= m_bombRadius + shipTargets[i].m_radius)
                            {
                                if (!shipTargets[i].m_isAlive)
                                {
                                    continue;
                                }
                                else
                                {
                                    shipTargets[i].m_isAlive = false;
                                    BombersNetworkManager.m_localPlayer.HitShipTargetPointCommand(shipTargets[i].m_shipID, shipTargets[i].m_index, m_bombInfo.GetJson());
                                }

                                if (!aCollision.transform.parent.parent.parent.gameObject.GetComponent <ShipController>().IsAlive())
                                {
                                    BombersNetworkManager.m_localPlayer.DestroyShipCommand(aCollision.transform.parent.parent.parent.gameObject.GetComponent <ShipController>().m_shipID, m_bombInfo.GetJson());
                                    break;
                                }
                            }
                        }
                        BombersNetworkManager.m_localPlayer.DeleteBombCommand(this, 1);
                    }
                }
                NetworkServer.Destroy(gameObject);
            }
            else
            {
                if (transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().enabled == true)
                {
                    try
                    {
                        if (aCollision.gameObject.layer == 4)
                        {
                            Instantiate((GameObject)Resources.Load("BombWaterExplosion"), transform.position, Quaternion.identity);
                        }
                        else if ((BombersPlayerController.GetPlayer(m_bombInfo.m_shooter).m_team == 1 && aCollision.gameObject.layer == 16) || (BombersPlayerController.GetPlayer(m_bombInfo.m_shooter).m_team == 2 && aCollision.gameObject.layer == 17))
                        {
                            Instantiate((GameObject)Resources.Load("BombDud"), transform.position, Quaternion.identity);
                        }
                        else
                        {
                            Instantiate((GameObject)Resources.Load("BombExplosion"), transform.position, Quaternion.identity);
                        }
                        transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().enabled = false;
                        Destroy(gameObject);
                    }
                    catch
                    {
                        Instantiate((GameObject)Resources.Load("BombExplosion"), transform.position, Quaternion.identity);
                        transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().enabled = false;
                        Destroy(gameObject);
                    }
                }
            }
        }
        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();
        }
 private void initHelper(int in_team, BombersPlayerController in_parent)
 {
     m_parentController = in_parent;
     m_reticle          = gameObject.transform.Find("Pointer").gameObject;
 }
 public void Init(ShipController in_target, BombersPlayerController in_parent)
 {
     initHelper(in_target.m_team, in_parent);
     m_target = in_target.transform;
 }