コード例 #1
0
        public void DeleteBombCommand(BombController aBombController, int aID)
        {
            BombInfo aBombInfo = aBombController.BombInfo;

            m_gMan.CmdDeleteBomb(aBombInfo.GetJson(), aID);
        }
コード例 #2
0
        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);
                    }
                }
            }
        }