示例#1
0
    public virtual void UpdateCollect()
    {
        GameObject go = GameController.CurrentGamePlayerController.gameObject;

        if (go != null)
        {
            Vector3 playerPosition = go.transform.position;
            Vector3 itemPosition   = transform.position;

            if (Vector3.Distance(playerPosition, itemPosition) <= collectRange)
            {
                //foreach(Collider collide in Physics.OverlapSphere(transform.position, collectRange)) {

                GamePlayerController gamePlayerController = GameController.GetGamePlayerControllerObject(go, true);

                if (gamePlayerController != null && !gamePlayerController.controllerData.dying)
                {
                    if (gamePlayerController.IsPlayerControlled)
                    {
                        CollectContent();
                    }
                }
            }
        }
    }
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#3
0
    public override void Init()
    {
        if (gamePlayerController == null)
        {
            gamePlayerController = gameObject.FindTypeAboveRecursive <GamePlayerController>();
        }

        Load();

        if (currentItems != null)
        {
            foreach (GameObject go in currentItems)
            {
                if (go != null)
                {
                    if (go.transform != null)
                    {
                        Quaternion resetRotation = go.transform.rotation;
                        resetRotation.x       = 0;
                        resetRotation.y       = 0;
                        resetRotation.z       = 0;
                        go.transform.rotation = resetRotation;
                    }
                }
            }
        }
    }
示例#4
0
    void Start()
    {
        DontDestroyOnLoad(gameObject);
        var canvas = GameObject.Find("Canvas");

        m_roomui = canvas.GetComponent <RoomUI>();
        if (isLocalPlayer)
        {
            // 创建新接入的可控本地,具备发送Cmd能力
            s_localClient = this;

            Player playerInfo;
            ClientLoadUserData(out playerInfo);
            CmdAddPlayer(playerInfo);
        }
        else if (!m_player.Initialized)
        {
            // 创建新接入的远程
            Debug.LogFormat("New Client Connected.");
        }
        else         /*if (m_playerInfo.Initialized)*/
        // 创建已接入的远程,需要同步到本地
        {
            ClientAddPlayerToSlot();
        }
    }
    public void UpdateGameObjects()
    {
        if (string.IsNullOrEmpty(effectDestroy))
        {
            //effectDestroy = "effect-explosion";
        }
        if (string.IsNullOrEmpty(audioHit))
        {
            //audioHit = "attack-hit-1";
        }

        gamePlayerController = null;
        gameZoneActionAsset  = null;

        if (gamePlayerController == null)
        {
            gamePlayerController =
                gameObject.FindTypeAboveRecursive <GamePlayerController>();
        }
        if (gameZoneActionAsset == null)
        {
            gameZoneActionAsset =
                gameObject.FindTypeAboveRecursive <GameZoneActionAsset>();
        }
    }
示例#6
0
 public void Init(GamePlayerController owner, bool isline)
 {
     //初始化设置
     Owner       = owner;
     GuideUI     = Owner.transform.Find("GuideUI").gameObject;
     this.isLine = isline;
 }
示例#7
0
    public virtual void SetTarget(Transform targetTo)
    {
        targetNotFoundCycles = 0;
        target = targetTo;

        if (target != null)
        {
            if (type == "player")
            {
                gamePlayerController = target.gameObject.Get <GamePlayerController>();
                if (gamePlayerController != null)
                {
                    //..
                }
            }
            else if (type == GamePlayerIndicatorType.item)
            {
                if (gamePlayerItem == null)
                {
                    gamePlayerItem = target.gameObject.Get <GamePlayerItem>();
                    if (gamePlayerItem != null)
                    {
                        //..
                    }
                }
            }
        }
    }
示例#8
0
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        if (leftTimeBar == null)
        {
            this.leftTimeBar = GameObject.Find("LeftTimeBar");
        }
        if (countDownText == null)
        {
            this.countDownText = GameObject.Find("CountDown");
        }
        if (player == null)
        {
            this.player = GameObject.Find("Player");
        }
        if (finishText == null)
        {
            this.finishText = GameObject.Find("Finish");
        }
        if (gameDirector == null)
        {
            this.gameDirector = GameObject.Find("GameDirector");
        }

        playerScript    = player.GetComponent <GamePlayerController>();
        calcPointScript = gameDirector.GetComponent <CalcPoint>();

        BGM         = GameObject.Find("BGM");
        musicScript = BGM.GetComponent <BackGroundMusic>();

        startFlag     = false;
        coroutineFlag = true;
        deltaTime     = 0;
    }
 private void Start()
 {
     if (gamePlayerController == null)
     {
         gamePlayerController = GetComponent <GamePlayerController>();
     }
 }
 public virtual void FindGamePlayer()
 {
     if (gamePlayerController == null)
     {
         gamePlayerController = GetComponent <GamePlayerController>();
     }
 }
示例#11
0
 public void RemoveBuff(GamePlayerController player)
 {
     player.BuffCo?.Sub(Coefficient);
     if (Owner.GetPhotonView().IsMine)
     {
         PhotonNetwork.Destroy(Effect);
     }
 }
示例#12
0
    public override void Start()
    {
        base.Start();

        if (gamePlayerController == null)
        {
            gamePlayerController = GameController.CurrentGamePlayerController;
        }
    }
示例#13
0
 public override void GetBuff(GamePlayerController player)
 {
     Owner = player.gameObject;
     player.BuffCo.Add(Coefficient);
     if (Owner.GetPhotonView().IsMine)
     {
         Effect = PhotonNetwork.Instantiate("SpeedUpEffect", Vector3.zero, Quaternion.identity);
     }
 }
示例#14
0
    public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager,
                                                           GameObject lobbyPlayer, GameObject gamePlayer)
    {
        LobbyPlayer          lobby       = lobbyPlayer.GetComponent <LobbyPlayer> ();
        GamePlayerController localPlayer = gamePlayer.GetComponent <GamePlayerController> ();

        localPlayer.pname       = lobby.playerName;
        localPlayer.playerColor = lobby.playerColor;
        localPlayer.playerID    = lobby.playerID;
    }
示例#15
0
    static void fakeClientForEditor()
    {
        if (s_localClient != null)
        {
            return;
        }
        var prefab     = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Prefabs/GamePlayer.prefab");
        var gamePlayer = Instantiate(prefab);

        s_localClient = gamePlayer.GetComponent <GamePlayerController>();
    }
示例#16
0
        public override void GetBuff(GamePlayerController player)
        {
            Owner = player.gameObject;
            player.BuffCo.Add(Coefficient);
            if (Owner.GetPhotonView().IsMine)
            {
                Effect = PhotonNetwork.Instantiate("ShieldEffect", Vector3.zero, Quaternion.identity);
            }

            //tempeffect.GetComponentInChildren<ParticleSystem>().Play();
        }
    public override void Mount(GameObject go)
    {
        base.Mount(go);

        if (isMounted)
        {
            gamePlayerController = objectMounted.Get <GamePlayerController>();
        }

        MountVehicle();
    }
示例#18
0
 public virtual GamePlayerController GetController(Transform transform)
 {
     if (transform != null)
     {
         GamePlayerController gamePlayerController = transform.GetComponentInChildren <GamePlayerController>();
         if (gamePlayerController != null)
         {
             return(gamePlayerController);
         }
     }
     return(null);
 }
示例#19
0
 // This is called on the server when a client disconnects
 public override void OnServerDisconnect(NetworkConnection conn)
 {
     // Notify the game controller that a player disconnected
     foreach (PlayerController player in conn.playerControllers)
     {
         GamePlayerController playerController = player.gameObject.GetComponent <GamePlayerController>();
         if (playerController)
         {
             playerController.RpcRemovePlayer();
         }
     }
     QuitIfNoPlayers();
 }
    public virtual void FindPlayerCollisionParent()
    {
        if (gamePlayerControllerObject == null)
        {
            gamePlayerControllerObject = gameObject.FindTypeAboveObject <GamePlayerController>();
        }

        if (gamePlayerController == null &&
            gamePlayerControllerObject != null)
        {
            gamePlayerController = gamePlayerControllerObject.GetComponent <GamePlayerController>();
            CancelInvoke("FindPlayerCollisionParent");
        }
    }
示例#21
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     //if(isServer)
     {
         if (other.tag != "tongue")
         {
             GamePlayerController victim = other.GetComponent <GamePlayerController>();
             if (victim != null)
             {
                 size += victim.size;
                 victim.GotEaten();
             }
         }
     }
 }
示例#22
0
    public virtual void Boost(GameObject go)
    {
        LogUtil.Log("Boost:go", go.name);
        LogUtil.Log("Boost:boostGamePlayers", boostGamePlayers);
        LogUtil.Log("Boost:boostProjectiles", boostProjectiles);

        //

        if (!boostGamePlayers && !boostProjectiles)
        {
            return;
        }

        LogUtil.Log("Boost:boostGamePlayers", boostGamePlayers);
        LogUtil.Log("Boost:boostProjectiles", boostProjectiles);

        if (lastBoost + 3f < Time.time)
        {
            lastBoost = Time.time;
        }
        else
        {
            return;
        }

        if (boostGamePlayers)
        {
            GamePlayerController gamePlayerController = GameController.GetGamePlayerControllerObject(go, true);

            if (gamePlayerController != null)
            {
                if (gamePlayerController.IsPlayerControlled)
                {
                    LogUtil.Log("Boost:gamePlayerController.IsPlayerControlled", gamePlayerController.IsPlayerControlled);
                    gamePlayerController.Boost(boostForce);
                }
            }
        }

        if (boostProjectiles)
        {
            //GameProjectile projectile = GameController.GetGamePlayerControllerObject(go);

            //if(gamePlayerController != null) {
            //    gamePlayerController.Boost();
            //}
        }
    }
    public void UpdateGameObjects()
    {
        gamePlayerController = null;
        gameDamageManager    = null;

        if (gamePlayerController == null)
        {
            gamePlayerController = gameObject.FindTypeAboveRecursive <GamePlayerController>();
        }

        if (gameDamageManager == null)
        {
            gameDamageManager = gameObject.GetOrSet <GameDamageManager>();
            gameDamageManager.UpdateGameObjects();
        }
    }
    public void BroadcastGameLevelFinishData(bool showReplayCallout)
    {
        Debug.Log("Broadcast: BroadcastGameLevelFinishData:Starting");

        if (BroadcastNetworks.broadcastNetworksEnabled)
        {
            if (GameProfiles.Current.GetBroadcastRecordLevels())
            {
                if (BroadcastNetworks.IsRecording())
                {
                    Debug.Log("BroadcastGameLevelFinishData" + " record levels:" +
                              GameProfiles.Current.GetBroadcastRecordLevels());

                    BroadcastNetworks.StopRecording();

                    if (showReplayCallout)
                    {
                        ShowBroadcastRecordPlayShare();
                    }

                    GamePlayerRuntimeData runtimeData          = new GamePlayerRuntimeData();
                    GamePlayerController  gamePlayerController = GameController.CurrentGamePlayerController;

                    if (gamePlayerController != null)
                    {
                        runtimeData = gamePlayerController.runtimeData;
                    }

                    string word = GameCommunitySocialController.Instance.GetGameAdjective();

                    BroadcastNetworks.SetMetadata("about",
                                                  word + Locos.Get(LocoKeys.social_everyplay_game_results_message));

                    BroadcastNetworks.SetMetadata("game", Locos.Get(LocoKeys.app_display_name));
                    BroadcastNetworks.SetMetadata("level", Locos.Get(LocoKeys.game_type_arcade));
                    BroadcastNetworks.SetMetadata("level_name", Locos.Get(LocoKeys.game_type_arcade_mode));
                    BroadcastNetworks.SetMetadata("url", Locos.Get(LocoKeys.app_web_url));
                    BroadcastNetworks.SetMetadata("score", runtimeData.score.ToString("N0"));
                    BroadcastNetworks.SetMetadata("scores", runtimeData.scores.ToString("N0"));
                    BroadcastNetworks.SetMetadata("coins", runtimeData.coins.ToString("N0"));
                    BroadcastNetworks.SetMetadata("total_score", runtimeData.totalScoreValue.ToString("N0"));

                    Debug.Log("BroadcastGameLevelFinishData" + " runtimeData.scores:" + runtimeData.scores);
                }
            }
        }
    }
示例#25
0
    private void Awake()
    {
        DontDestroyOnLoad(this.gameObject);

        Cursor.lockState = CursorLockMode.Locked;

        game_state = GameState.MainMenu;
        game_state_change_event_args            = new GameStateChangeEventArgs();
        game_state_change_event_args.game_state = game_state;

        load_level_controller     = this.gameObject.AddComponent <GameLoadLevelController>();
        input_controller          = this.gameObject.GetComponent <GameInputController>();
        audio_controller          = this.gameObject.GetComponent <GameAudioController>();
        player_controller         = this.gameObject.GetComponent <GamePlayerController>();
        data_controller           = this.gameObject.GetComponent <GameDataController>();
        cutscene_controller       = this.gameObject.GetComponent <GameCutsceneController>();
        user_interface_controller = this.gameObject.GetComponent <GameUserInterfaceController>();
    }
示例#26
0
    public virtual bool ShouldCountHit(Collider collider)
    {
        if (collider != null)
        {
            string objName = collider.transform.name;
            if (!objName.Contains("DragColliderObject") &&
                (objName.Contains("GamePlayerObject") ||
                 objName.Contains("GamePlayerEnemy")))
            {
                GamePlayerController player = collider.transform.gameObject.GetComponent <GamePlayerController>();
                if (player != null)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
示例#27
0
    void FindPlayer()
    {
        Debug.Log("FindPlayer");

        if (thisPlayer == null)
        {
            GameObject[] playerLists = GameObject.FindGameObjectsWithTag("networkPlayer");
            for (int i = 0; i < playerLists.Length; i++)
            {
                if (playerLists [i].GetComponent <GamePlayerController> ().isLocalPlayer)
                {
                    thisPlayer     = playerLists [i];
                    thisPlayerInfo = playerLists [i].GetComponent <GamePlayerController> ();
                    thisPlayerInfo.MeLabel.SetActive(true);
                    break;
                }
            }
        }
    }
示例#28
0
    // Use this for initialization
    void Start()
    {
        gamePlayerController = new GamePlayerController();

        inGameStateManager = new InGameStateManager();
        inGameStateManager.Init();

        inGameObjManager = new InGameObjManager();
        inGameObjManager.Init();

        inGamePlayerManager = new InGamePlayerManager();
        inGamePlayerManager.Init();

        inGameMapManager = new InGameMapManager();
        inGameMapManager.Init();

        gameEffectManager = new GameEffectManager();

        imageEffect_MoblieBloom = GameObject.Find("Main Camera").GetComponent <ImageEffect_MoblieBloom>();
    }
 // This is called on the server when a client disconnects
 public override void OnServerDisconnect(NetworkConnection conn)
 {
     base.OnServerDisconnect(conn);
     // Notify the game controller that a player disconnected
     foreach (PlayerController player in conn.playerControllers)
     {
         GamePlayerController playerController = player.gameObject.GetComponent <GamePlayerController>();
         if (playerController)
         {
             gameManager.RemovePlayer(playerController);
         }
     }
     // if the number of players drops to 0, notify GameLift to terminate the instance
     // NOTE: This may not be desirable if you want to give more time to poplate a running
     // server instance.
     if (numPlayers <= 0 && isHeadlessServer)
     {
         TerminateSession();
     }
 }
示例#30
0
    public void HandleCollision(Collision collision)
    {
        // If the human player hit us, check the score/choice and correct or incorrect message broadcast

        //LogUtil.Log("GameObjectChoice:OnCollisionEnter:" + collision.transform.name);

        GameObject go = collision.collider.transform.gameObject;

        //LogUtil.Log("GameObjectChoice:go:" + go.name);

        if (go.name.Contains("GamePlayerObject"))
        {
            gamePlayerController = GameController.GetGamePlayerController(go);

            if (gamePlayerController != null)
            {
                if (gamePlayerController.IsPlayerControlled)
                {
                    HandleChoiceData();
                }
            }
        }

        if (gamePlayerController == null &&
            (go.name.Contains("GamePlayerCollider")))
        {
            LogUtil.Log("GameObjectChoice:GamePlayerCollider:" + go.name);

            gamePlayerController = GameController.GetGamePlayerControllerParent(go);

            if (gamePlayerController != null)
            {
                LogUtil.Log("GameObjectChoice:gamePlayerController:" + gamePlayerController.name);

                if (gamePlayerController.IsPlayerControlled)
                {
                    HandleChoiceData();
                }
            }
        }
    }