Inheritance: Photon.PunBehaviour
示例#1
0
    public void TakeDamage(int amount)
    {
        currentHealth -= amount;
        PhotonView pv = GetComponent <PhotonView>();

        if (pv != null)
        {
            pv.RPC("OnChangeHealth", PhotonTargets.All);
        }
        else
        {
            Debug.Log("Error in getting photonview");
        }

        if (currentHealth <= 500 && pv.GetComponent <IMAI>() == null)
        {
            RandomMatchmaker rm = GameObject.FindObjectOfType <RandomMatchmaker>();
            rm.createRecoveryRegion = true;
        }
        if (currentHealth <= 0)
        {
            currentHealth = 0;
            Die();
        }
    }
示例#2
0
	void Start () {
        instance = this;
        PhotonNetwork.ConnectUsingSettings("1");
        PhotonNetwork.logLevel = PhotonLogLevel.Full;
        PhotonNetwork.sendRate = 30;
        PhotonNetwork.sendRateOnSerialize = 30;
        spawnedList = new List<GameObject>();
    }
示例#3
0
    void Die()
    {
        PhotonView pv = GetComponent <PhotonView>();

        if (pv.instantiationId == 0)
        {
            Destroy(gameObject);
        }
        else
        {
            if (pv.isMine)
            {
                if (gameObject.tag == "Player" && GetComponent <IMAI>() == null)
                {
                    RandomMatchmaker rm = GameObject.FindObjectOfType <RandomMatchmaker>();
                    rm.mainCamera.enabled = true;
                    GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimer = 5f;

                    PhotonNetwork.player.SetScore(0);
                }
                else
                {
                    RandomMatchmaker rm = GameObject.FindObjectOfType <RandomMatchmaker>();
                    if (GetComponent <IMAI>().num == 0)
                    {
                        GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimerAI = 5f;
                    }
                    else if (GetComponent <IMAI>().num == 1)
                    {
                        GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimerAI1 = 5f;
                    }
                    else if (GetComponent <IMAI>().num == 2)
                    {
                        GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimerAI2 = 5f;
                    }
                    else if (GetComponent <IMAI>().num == 3)
                    {
                        GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimerAI3 = 5f;
                    }
                    else
                    {
                        GameObject.FindObjectOfType <RandomMatchmaker>().respawnTimerAI4 = 5f;
                    }
                }

                PhotonNetwork.Destroy(gameObject);
                Vector3    explosionPosition = gameObject.transform.position;
                GameObject explosion         = PhotonNetwork.Instantiate("ObjectExplosion",
                                                                         explosionPosition, Quaternion.identity, 0);
            }
        }
    }
示例#4
0
#pragma warning disable 0414 // Type or member is obsolete
    // Use this for initialization
    void Start () {
        PhotonNetwork.player.customProperties["Deaths"] = 0;
        PhotonNetwork.player.SetCustomProperties(PhotonNetwork.player.customProperties);
        rm = GameObject.FindGameObjectWithTag("scripts").GetComponent<RandomMatchmaker>();
        currentHitPoints = hitPoints;
        calculator = GameObject.FindGameObjectWithTag("scripts").GetComponent<Calculator>();
		image1 = Resources.Load<Sprite> ("HealthBar1");
		image2 = Resources.Load<Sprite> ("HealthBar2");
		image3 = Resources.Load<Sprite> ("HealthBar3");
		image4 = Resources.Load<Sprite> ("HealthBar4");
		image5 = Resources.Load<Sprite> ("HealthBar5");
		image6 = Resources.Load<Sprite> ("HealthBar6");
		image7 = Resources.Load<Sprite> ("HealthBar7");
        rb = GetComponent<Rigidbody>();
    }
示例#5
0
    private void OnLevelWasLoaded(int level)
    {
        if (level == MAINMENU_SCENE_NUMBER)
        {
            // Skip login from other scenes if already logged in
            if (IsLogedIn)
            {
                GameObject.Find("Canvas").transform.FindChild("Login").gameObject.SetActive(false);
                GameObject.Find("Canvas").transform.FindChild("MainMenu").gameObject.SetActive(true);
            }
            // Update the profile to the server if not updated yet
            if (IsLogedIn && !AlreadyUpdated)
            {
                Profile oldProfile = ProfileMessenger.GetProfileByEmail(UserName);
                oldProfile.numGamesPlayed  += 1;
                oldProfile.numDeath        += Death;
                oldProfile.numPlayerKilled += Kill;
                if (Won)
                {
                    oldProfile.numGamesWon++;
                }
                else
                {
                    oldProfile.numGamesLost++;
                }
                ResetStats();
                ProfileMessenger.SubmitNewProfile(oldProfile);
            }
        }
        // Inform RandomMatchMaker if the player has chosen to load from save file
        if (level == MATCHING_SCENE_NUMBER)
        {
            RandomMatchmaker rm = GameObjectFinder.FindRandomMatchMaker();
            rm.LoadedFromFile = LoadedFromFile;
        }

        if (level == RESULT_SCENE_NUMBER)
        {
            // Display stats in result scene
            ResultPageController rpc = GameObjectFinder.FindResultPageController();
            rpc.IsWinner = Won;
            rpc.UserName = UserName;
            rpc.Kill     = Kill;
            rpc.Death    = Death;
        }
    }
    // Use this for initialization
    void Start()
    {
        instance = this;

        ToggleSPBasedOnCheckbox();
        if (singlePlayer == false)
        {
            roomOptions = new RoomOptions()
            {
                isVisible = true, maxPlayers = 2
            };
            PhotonNetwork.ConnectUsingSettings("0.1");
        }
        else
        {
            PhotonNetwork.offlineMode = true;
            PhotonNetwork.JoinRandomRoom();
        }
    }
示例#7
0
    void Start()
    {
        locker = true;
        board = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent<Board>();
        playerText = GameObject.FindGameObjectWithTag("PlayerTextTag").GetComponent<Text>();
        timeText = GameObject.FindGameObjectWithTag("TimeTextTag").GetComponent<Text>();
        cameraButton = GameObject.FindGameObjectWithTag("CameraToggleTag").GetComponent<Button>();
        playerText.enabled = false;
        timeText.enabled = false;
        cameraButton.enabled = false;
        cameraButton.GetComponentInChildren<RawImage>().enabled = false;
        cameraButton.GetComponentInChildren<Text>().enabled = false;
        board = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent<Board>();
        networkManager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent<RandomMatchmaker>();

        players = new PlayerAbstract[6];
        allPlayers[0].GetComponent<PlayerManager>().Link();
        allPlayers[1].GetComponent<PlayerManager>().Link();
        allPlayers[2].GetComponent<PlayerManager>().Link();
        allPlayers[3].GetComponent<PlayerManager>().Link();
        allPlayers[4].GetComponent<PlayerManager>().Link();
        allPlayers[5].GetComponent<PlayerManager>().Link();
        allPlayers[6].GetComponent<AIManager>().Link();
        allPlayers[7].GetComponent<AIManager>().Link();
        allPlayers[8].GetComponent<AIManager>().Link();
        allPlayers[9].GetComponent<AIManager>().Link();
        allPlayers[10].GetComponent<AIManager>().Link();
        allPlayers[11].GetComponent<AIManager>().Link();

        allPlayers[0].GetComponent<PlayerManager>().SetActive(false);
        allPlayers[1].GetComponent<PlayerManager>().SetActive(false);
        allPlayers[2].GetComponent<PlayerManager>().SetActive(false);
        allPlayers[3].GetComponent<PlayerManager>().SetActive(false);
        allPlayers[4].GetComponent<PlayerManager>().SetActive(false);
        allPlayers[5].GetComponent<PlayerManager>().SetActive(false);
       

        currentCamera = (allPlayers[0].GetComponent<PlayerManager>()).
            cameras[0].GetComponent<Camera>();
        currentCamera.enabled = true;
        currentCamera.GetComponent<AudioListener>().enabled = true;

        DisableAllExtraElements();

        winText = GameObject.FindGameObjectWithTag("WinTextTag").GetComponent<Text>();
        winPanel = GameObject.FindGameObjectWithTag("WinPanelTag").GetComponent<RawImage>();
        winPanel.enabled = false;
        winText.enabled = false;

        soundButtonText = GameObject.
            FindGameObjectWithTag("SoundButton").GetComponentInChildren<Text>();

        musicButtonText = GameObject.
            FindGameObjectWithTag("MusicButton").GetComponentInChildren<Text>();

        timeMode = obstacleMode = flyMode = hintMode = maniaMode = false;
        localMode = false;

        AINum = 0;
        playerNum = 2;

        board.ClearCurrentHoodle();
        currentPlayer = 0;

        timeInterval = 15;
        playerTimeInterval = new int[6];
        for (int i = 0; i < 6; i++) {
            playerTimeInterval[i] = timeInterval;
        }
        

        //for delay
        delayLock = false;
        delayTimer = 0.0f;

        bgm = GameObject.FindGameObjectWithTag("BGM").GetComponent<AudioSource>();
        sound = true;
        bgm.mute = false;

        roomPanel1.SetActive(false);
        roomPanel2.SetActive(false);
        gamePanel.SetActive(false);

        roomList = new Queue();
		isWaiting = false;
		onAIAction = false;

        aIactionQueue = new Queue();
    }
 void Start()
 {
     matchSettings = GameObject.Find("ScriptsManager").GetComponent <RandomMatchmaker> ();
 }
示例#9
0
    // Update is called once per frame
    void Update()
    {
        if (!ai)
        {
            float x = Input.GetAxis("Accelerate") * Time.deltaTime * 10.0f * acceleratetAmount;
            var   y = Input.GetAxis("Rotate") * Time.deltaTime * 150.0f;

            if (accelerateTime > 0)
            {
                accelerateTime -= Time.deltaTime;
                if (accelerateTime <= 0)
                {
                    SetAcceleration(prevAcceleration);
                    acceleratetAmount = 1;
                }
            }

            if (slowTime > 0)
            {
                slowTime -= Time.deltaTime;
                x         = (float)(x * 0.65);
                y         = (float)(y * 0.65);
            }
            transform.Rotate(0, 0, y);
            transform.Translate(0, x, 0);

            if (Input.GetButton("Fire1") && Time.time > nextFire)
            {
                nextFire = Time.time + fireRate;
                CmdFire1();
            }
            Camera.main.transform.eulerAngles = new Vector3(0, 0, 0);
            GetComponentsInChildren <Camera>()[1].transform.eulerAngles = new Vector3(0, 0, 0);
            RandomMatchmaker rm = GameObject.FindObjectOfType <RandomMatchmaker>();
            rm.playerPos = gameObject.transform.position;
        }
        else
        {
            if (change == 0)
            {
                if (Random.Range(0f, 1f) >= 0.25f)
                {
                    randomX = Random.Range(0.7f, 1f);
                }
                else
                {
                    randomX = Random.Range(-1f, 1f);
                }
                randomY = Random.Range(-1f, 1f);
                change  = 100f;
            }
            else
            {
                change--;
            }

            float x = randomX * Time.deltaTime * 10.0f * acceleratetAmount;
            var   y = randomY * Time.deltaTime * 150.0f;

            if (accelerateTime > 0)
            {
                accelerateTime -= Time.deltaTime;
                if (accelerateTime <= 0)
                {
                    SetAcceleration(prevAcceleration);
                    acceleratetAmount = 1;
                }
            }

            if (slowTime > 0)
            {
                slowTime -= Time.deltaTime;
                x         = (float)(x * 0.65);
                y         = (float)(y * 0.65);
            }
            transform.Rotate(0, 0, y);
            transform.Translate(0, x, 0);

            if (Time.time > nextFire)
            {
                nextFire = Time.time + fireRate;
                CmdFire1();
            }

            //Caused bug that player position affected by AI
            //RandomMatchmaker rm = GameObject.FindObjectOfType<RandomMatchmaker>();
            //rm.playerPos = gameObject.transform.position;
        }
    }
示例#10
0
	void Start(){
		hoi = GameObject.FindGameObjectWithTag("scripts").GetComponent<RandomMatchmaker>();
	}
示例#11
0
	// Use this for initialization
	void Start () {
        paused = false;
        rm = GameObject.FindObjectOfType<RandomMatchmaker>();
	}
示例#12
0
    void Start()
    {
        locker               = true;
        board                = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent <Board>();
        playerText           = GameObject.FindGameObjectWithTag("PlayerTextTag").GetComponent <Text>();
        timeText             = GameObject.FindGameObjectWithTag("TimeTextTag").GetComponent <Text>();
        cameraButton         = GameObject.FindGameObjectWithTag("CameraToggleTag").GetComponent <Button>();
        playerText.enabled   = false;
        timeText.enabled     = false;
        cameraButton.enabled = false;
        cameraButton.GetComponentInChildren <RawImage>().enabled = false;
        cameraButton.GetComponentInChildren <Text>().enabled     = false;
        board          = GameObject.FindGameObjectWithTag("HoldBoard").GetComponent <Board>();
        networkManager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <RandomMatchmaker>();

        players = new PlayerAbstract[6];
        allPlayers[0].GetComponent <PlayerManager>().Link();
        allPlayers[1].GetComponent <PlayerManager>().Link();
        allPlayers[2].GetComponent <PlayerManager>().Link();
        allPlayers[3].GetComponent <PlayerManager>().Link();
        allPlayers[4].GetComponent <PlayerManager>().Link();
        allPlayers[5].GetComponent <PlayerManager>().Link();
        allPlayers[6].GetComponent <AIManager>().Link();
        allPlayers[7].GetComponent <AIManager>().Link();
        allPlayers[8].GetComponent <AIManager>().Link();
        allPlayers[9].GetComponent <AIManager>().Link();
        allPlayers[10].GetComponent <AIManager>().Link();
        allPlayers[11].GetComponent <AIManager>().Link();

        allPlayers[0].GetComponent <PlayerManager>().SetActive(false);
        allPlayers[1].GetComponent <PlayerManager>().SetActive(false);
        allPlayers[2].GetComponent <PlayerManager>().SetActive(false);
        allPlayers[3].GetComponent <PlayerManager>().SetActive(false);
        allPlayers[4].GetComponent <PlayerManager>().SetActive(false);
        allPlayers[5].GetComponent <PlayerManager>().SetActive(false);


        currentCamera = (allPlayers[0].GetComponent <PlayerManager>()).
                        cameras[0].GetComponent <Camera>();
        currentCamera.enabled = true;
        currentCamera.GetComponent <AudioListener>().enabled = true;

        DisableAllExtraElements();

        winText          = GameObject.FindGameObjectWithTag("WinTextTag").GetComponent <Text>();
        winPanel         = GameObject.FindGameObjectWithTag("WinPanelTag").GetComponent <RawImage>();
        winPanel.enabled = false;
        winText.enabled  = false;

        soundButtonText = GameObject.
                          FindGameObjectWithTag("SoundButton").GetComponentInChildren <Text>();

        musicButtonText = GameObject.
                          FindGameObjectWithTag("MusicButton").GetComponentInChildren <Text>();

        timeMode  = obstacleMode = flyMode = hintMode = maniaMode = false;
        localMode = false;

        AINum     = 0;
        playerNum = 2;

        board.ClearCurrentHoodle();
        currentPlayer = 0;

        timeInterval       = 15;
        playerTimeInterval = new int[6];
        for (int i = 0; i < 6; i++)
        {
            playerTimeInterval[i] = timeInterval;
        }


        //for delay
        delayLock  = false;
        delayTimer = 0.0f;

        bgm      = GameObject.FindGameObjectWithTag("BGM").GetComponent <AudioSource>();
        sound    = true;
        bgm.mute = false;

        roomPanel1.SetActive(false);
        roomPanel2.SetActive(false);
        gamePanel.SetActive(false);

        roomList   = new Queue();
        isWaiting  = false;
        onAIAction = false;

        aIactionQueue = new Queue();
    }