public void Login(GameObject emailTextField)
    {
        string email = emailTextField.GetComponent <Text>().text;

        if (email == "")
        {
            AlertPage.SetActive(true);
            AlertPage.transform.GetChild(0).GetComponent <Text>().text = "Invalid Email Address";
        }
        else
        {
            try {
                bool outcome = GlobalState.LoadProfileWithEmail(email);
                if (outcome == false)
                {
                    Debug.LogWarning("login failed");
                }
                else
                {
                    GameObjectFinder.FindProfileHandler().LoggedIn(email);
                    GoToMainMenu();
                }
            }
            catch (ProfileMessagingException e) {
                DisplayError(e);
            }
        }
    }
    // for load button
    public void LoadGame()
    {
        ProfileHandler ph = GameObjectFinder.FindProfileHandler();

        ph.LoadedFromFile = true;
        StateController.SwitchToMatching();
    }
Exemplo n.º 3
0
    // Save the game
    public void SaveButtonOnClick()
    {
        _currentCoolDown = _saveCoolDown;
        GameSaver gs = GameObjectFinder.FindGameSaver();

        gs.Save();
    }
Exemplo n.º 4
0
 /// <summary>
 /// 阿罵 脫離Joint控制。
 /// </summary>
 public void SetJointNull()
 {
     IsNotCollision = true;
     GetComponent <FixedJoint>().connectedBody = null;
     GameObjectFinder.GetObj("NPC_GrandMother").GetComponent <Rigidbody>().useGravity = false;
     GameObjectFinder.GetObj("Audio").GetComponent <AudioSource>().Play();
 }
Exemplo n.º 5
0
 private void OnLevelWasLoaded(int level)
 {
     if (level == GAMEPLAY_SCENE_NUMBER)
     {
         if (!LoadedFromFile)
         {
             // Initialise game normally
             InitialiseGamePlay();
         }
         else
         {
             // Master client loads from the save file and allocate instantiated
             // characters to other clients according to user name
             if (PhotonNetwork.isMasterClient)
             {
                 GameLoader gl   = GameObjectFinder.FindGameLoader();
                 GameSave   save = gl.ReadFile();
                 gl.Load(save);
             }
         }
     }
     if (level == MAINMENU_SCENE_NUMBER)
     {
         Destroy(this.gameObject);
     }
     if (level == RESULT_SCENE_NUMBER)
     {
         PhotonNetwork.Disconnect();
     }
 }
    // for multiPlayer button
    public void GoToQuickMatch()
    {
        ProfileHandler ph = GameObjectFinder.FindProfileHandler();

        ph.LoadedFromFile = false;
        StateController.SwitchToMatching();
    }
Exemplo n.º 7
0
    // Handle different conditions when the player joined quick match
    public override void OnJoinedRoom()
    {
        PhotonNetwork.playerName =
            GameObjectFinder.FindProfileHandler().UserName;
        if (PhotonNetwork.playerList.Length == 1)
        {
            if (LoadedFromFile && LoadFileExists())
            {
                _status = "Save loaded, Waiting For other players to join in.";
            }
            else if (LoadedFromFile && !LoadFileExists())
            {
                _status = "Save file not found, Please return to main menu.";
                PhotonNetwork.Disconnect();
            }
            else
            {
                _status = "Waiting For other players to join in.";
            }

            StartCoroutine("CheckForPlayers");
        }
        else
        {
            _countdownStarted = true;
            _status           = "Other players found, game will start in: ";
            this.photonView.RPC("ResetCountDown", PhotonTargets.All);
        }
    }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     if (HintAudio)
     {
         GameObjectFinder.GetObj("Audio").GetComponent <AudioSource>().PlayOneShot(HintAudio);
     }
 }
 private void Start()
 {
     _mainPlayer = GameObjectFinder.FindMainPlayer();
     if (_mainPlayer != null)
     {
         _speakerIcon = _mainPlayer.transform.GetChild(2).GetChild(1).gameObject;
     }
 }
Exemplo n.º 10
0
 // Update the profile in profile handler
 public void UpdateProfile(bool win)
 {
     if (photonView.isMine)
     {
         ProfileHandler ph = GameObjectFinder.FindProfileHandler();
         ph.UpdateProfile(this.NumKilled, this.NumDeath, win);
     }
 }
Exemplo n.º 11
0
 private void sendStationPassengers()
 {
     Station[] stations = GameObjectFinder.All <Station>();
     foreach (Station station in stations)
     {
         rpcCallSender.StationPassengers(station);
     }
 }
Exemplo n.º 12
0
 public AbstractScene(SceneManager manager, GameObjectFactory<string> resourceFactory, GameObjectFinder finder, AbstractInput input)
 {
     sceneManager = manager;
     this.resourceFactory = resourceFactory;
     this.gameObjectFinder = finder;
     this.input = input;
     completed = false;
     permitUnloadResources = true;
     camera = Camera.main;
 }
Exemplo n.º 13
0
 public AbstractScene(SceneManager manager, GameObjectFactory <string> resourceFactory, GameObjectFinder finder, AbstractInput input)
 {
     sceneManager          = manager;
     this.resourceFactory  = resourceFactory;
     this.gameObjectFinder = finder;
     this.input            = input;
     completed             = false;
     permitUnloadResources = true;
     camera = Camera.main;
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     NPC_GrandMother   = GameObjectFinder.GetObjTransform("NPC_GrandMother");
     NPC_Spawn_Postion = GameObjectFinder.GetObjTransform("NPC_Spawn_Postion");
     NPC_MAN_Parent    = GameObjectFinder.GetObjTransform("NPC_MAN_Parent");
     Moto_Spawn_Parent = GameObjectFinder.GetObjTransform("Moto_Spawn_Parent");
     ccMessage.f_AddListener(GameMessage.TaxiCollision, TaxiCollision);
     ccMessage.f_AddListener(GameMessage.ResetGame, ResetGame);
     Invoke("SpawnNPC", NPC_Spawn_Time);
 }
Exemplo n.º 15
0
 private void Start()
 {
     this._healthBarUI = this.GetComponent <HealthBarUI>();
     CharId            = photonView.viewID;
     // Find the user name from profile handler class
     if (photonView.isMine)
     {
         UserName = GameObjectFinder.FindProfileHandler().UserName;
     }
 }
Exemplo n.º 16
0
    // Switch to game play after countdown finished
    public void CountdownFinished()
    {
        GameController gc = GameObjectFinder.FindGameController();

        gc.LoadedFromFile = LoadedFromFile;
        if (PhotonNetwork.isMasterClient)
        {
            PhotonNetwork.LoadLevel("scenes/gameplay");
        }
    }
    private GameObject find(string gameObjectName)
    {
        GameObject gameObject = GameObjectFinder.WithName(gameObjectName);

        if (gameObject == null)
        {
            throw new GameObjectNotFoundException(gameObjectName);
        }
        return(gameObject);
    }
Exemplo n.º 18
0
    void SpawnMoto()
    {
        GameObject MotoCyclePrefab = GameObjectFinder.GetObj("MotorCycle");
        Vector3    MotoGenPos      = /*Vector3.right * 4.22f + Vector3.back * 10 + Vector3.down * 4*/ Moto_Spawn_Parent.position;

        //Debug.LogError( MotoGenPos );
        MotoCycleInstance = Instantiate(MotoCyclePrefab,
                                        MotoGenPos, Quaternion.identity);
        MotoCycleInstance.transform.parent = Moto_Spawn_Parent.transform;
    }
Exemplo n.º 19
0
    // Update number of kills and handle game state if game ends
    public void Killed()
    {
        NumKilled++;
        GameController gc = GameObjectFinder.FindGameController();

        if (GameController.CheckIfGameEnds())
        {
            UpdateProfile(true);
            gc.DisplayGameOverMessage();
        }
    }
Exemplo n.º 20
0
    // Find another character and focus camera on the character
    private void FocusCameraOnOtherPlayer()
    {
        GameObject anotherPlayer = GameObjectFinder.FindAnotherPlayerAlive();

        transform.FindChild("CameraRig").gameObject.SetActive(false);
        GameObject cameraRig = anotherPlayer.transform.FindChild("CameraRig").gameObject;

        cameraRig.GetComponent <CameraControl>().enabled           = true;
        cameraRig.GetComponentInChildren <Camera>().enabled        = true;
        cameraRig.GetComponentInChildren <AudioListener>().enabled = true;
    }
Exemplo n.º 21
0
 /// <summary>
 /// Show 結束動畫
 /// </summary>
 void ShowCutScene()
 {
     foreach (var item in FindObjectsOfType <Camera>())
     {
         if (item.transform.parent.name.Contains("CutScene") == false)
         {
             item.gameObject.SetActive(false);
         }
     }
     GameObjectFinder.GetObj("CutScene").SetActive(true);
 }
Exemplo n.º 22
0
 // Use this for initialization
 private void Start()
 {
     LoadedFromFile = false;
     IsLogedIn      = false;
     AlreadyUpdated = true;
     DontDestroyOnLoad(this.gameObject);
     if (GameObjectFinder.FindAllProfileHandler().Length == 2)
     {
         Destroy(this.gameObject);
     }
 }
Exemplo n.º 23
0
 override public void Awake()
 {
     // Init UI
     lblStatus   = GameObjectFinder.FindByName(this.gameObject, "lblStatus").gameObject.GetComponent <Text>();
     lblBattery  = GameObjectFinder.FindByName(this.gameObject, "lblBattery").gameObject.GetComponent <Text>();
     lblEmission = GameObjectFinder.FindByName(this.gameObject, "lblEmission").gameObject.GetComponent <Text>();
     lblDepth    = GameObjectFinder.FindByName(this.gameObject, "lblDepth").gameObject.GetComponent <Text>();
     // Set Depth
     SetEmittedRate();
     lblDepth.text = $"{Mathf.RoundToInt(Mathf.Abs(this.gameObject.transform.position.y)).ToString()} m";
 }
 public static GameObject FindCharacterWithUserName(string userName)
 {
     GameObject[] characters = GameObjectFinder.FindAllCharacters();
     foreach (GameObject character in characters)
     {
         if (character.GetComponent <Character>().UserName == userName)
         {
             return(character);
         }
     }
     return(null);
 }
 private void Start()
 {
     GameObject[] players = GameObjectFinder.FindAllCharacters();
     foreach (GameObject player in players)
     {
         Renderer miniMapDot = player.transform.GetChild(4).gameObject.GetComponent <Renderer>();
         if (player.GetPhotonView().isMine)
         {
             miniMapDot.material = Resources.Load <Material>("Materials/Blue");
             break;
         }
     }
 }
Exemplo n.º 26
0
    // Cause damage to character in lava and handle if death of player trigger termination of the game
    private IEnumerator Damage(Character player)
    {
        yield return(new WaitForSeconds(HealthDropSecondsInterval));

        while (_characterList.Contains(player))
        {
            player.TakeDamage(HealthDropPerTime);
            if (GameController.CheckIfGameEnds() && !GameObjectFinder.FindMainCharacter().IsDead)
            {
                GameObjectFinder.FindMainCharacter().UpdateProfile(true);
            }
            yield return(new WaitForSeconds(HealthDropSecondsInterval));
        }
    }
Exemplo n.º 27
0
        // Start is called before the first frame update
        public void Start()
        {
            IsEnabled = false;

            engine = GameObjectFinder.FindByName(this.gameObject, "Engine");

            anim = engine.GetComponent <Animation>();
            anim.AddClip(Utils.Helper.Bundle.LoadAsset <AnimationClip>("Drilling"), "Drilling");

            btnActivate = GameObjectFinder.FindByName(this.gameObject, "btnActivate").GetComponent <Button>();
            btnActivate.onClick.AddListener(() => StartNStop());

            StartNStop();
        }
Exemplo n.º 28
0
    // Update is called once per frame
    private void Update()
    {
        if (!photonView.isMine)
        {
            return;
        }

        // Set controllable for current character
        if (!_controlling && PhotonNetwork.playerName == this.gameObject.GetComponent <Character>().UserName)
        {
            SetControllable();
            _controlling = true;
        }

        // Detect user input of movement
        GameObject joyStick = GameObjectFinder.FindJoyStick();

        if (joyStick == null)
        {
            return;
        }

        // Handle joystick input to move the character
        VirtualJoyStick vjs = joyStick.GetComponent <VirtualJoyStick>();
        Vector3         joyStickMovement = vjs.GetStickPosition();

        if (joyStickMovement != Vector3.zero)
        {
            _rb.AddForce(joyStickMovement * VELOCITY, ForceMode.Acceleration);
        }
        _rb.velocity = Vector3.ClampMagnitude(_rb.velocity, MAX_VELOCITY);

        // Handle joystick input to rotate the character towards
        // the same direction as the joystick
        if (!joyStickMovement.Equals(Vector3.zero))
        {
            Vector3 targetDir = joyStickMovement;
            float   step      = 10;
            Vector3 newDir    = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0F);
            _lastRotation      = Quaternion.LookRotation(newDir);
            transform.rotation = _lastRotation;
            photonView.RPC("PlayAnim", PhotonTargets.All, "Move|Move");
        }
        else
        {
            transform.rotation = _lastRotation;
            photonView.RPC("PlayAnim", PhotonTargets.All, "Move|Idle");
        }
    }
Exemplo n.º 29
0
    // Sets the state of the ground
    public void SetGround(float scale, float time)
    {
        GroundController gc = GameObjectFinder.FindGroundController();

        if (PhotonNetwork.connected)
        {
            gc.SetTimePassedForAll(time);
            gc.SetScaleForAll(scale);
        }
        else
        {
            gc.TimePassed           = time;
            gc.transform.localScale = new Vector3(scale, 1, scale);
        }
    }
Exemplo n.º 30
0
 /// <summary>
 /// 計程車碰撞到摩托車,產生特效,解開Joint
 /// </summary>
 /// <param name="collision"></param>
 public void OnCollisionEnter(Collision collision)
 {
     if (CanPerformCollision)
     {
         if (collision.collider.name.Equals(MotoName))
         {
             CanPerformCollision = false;
             ccMessage.f_Broadcast(GameMessage.TaxiCollision);
             collision.collider.GetComponent <MotoPlayer>().SetJointNull();
             Instantiate(GameObjectFinder.GetObj("FX_Hit_01"),
                         collision.transform.position - Vector3.forward * 4 + Vector3.up * 4, Quaternion.identity);
             CancelInvoke("ResetGame");
         }
     }
 }
 // Check if game objects have been found
 private void Update()
 {
     if (_mainPlayer == null)
     {
         _mainPlayer = GameObjectFinder.FindMainPlayer();
         if (_mainPlayer != null)
         {
             _speakerIcon = _mainPlayer.transform.GetChild(2).GetChild(1).gameObject;
         }
         else
         {
             return;
         }
     }
 }
Exemplo n.º 32
0
 public TouchSensor(AbstractInput input, GameObjectFinder gameObjectFinder)
 {
     this.input = input;
     this.gameObjectFinder = gameObjectFinder;
 }