Inheritance: Photon.MonoBehaviour
Example #1
0
 void Start()
 {
     photonView = GetComponent<PhotonView> ();
     NAMEPLATE = gameObject.GetComponent<TextMesh>();
     playerName = GetComponentInParent<PlayerStatus> ().playerName;
     photonView.RPC ("setName", PhotonTargets.All, playerName);
 }
Example #2
0
	void Start () {
		pView = GetComponent<PhotonView>();
		rc = GetComponent<RocketControl>();
		if(pView.isMine)
			Respawn();

	}
 // Use this for initialization
 void Start()
 {
     view = GetComponent <PhotonView> (); //get the player's photon view
     name = view.owner.name; //set the name to the owner of this object's photon view
     textMesh = gameObject.transform.FindChild ("TextMesh").gameObject;
     textMesh.GetComponent<TextMesh> ().text = name;
 }
    void Awake()
    {
		playerAudio = transform.parent.GetComponent<PlayerAudio>();
        jetpackParticles = transform.FindChild("Particle Emitter").GetComponent<ParticleSystem>();

		playerAnimPhotonView = GetComponent<PhotonView>();
    }
Example #5
0
	void OnTriggerEnter(Collider other){

		photonView = gameObject.GetComponent<PhotonView> ();

//		Debug.Log ("OnTriggerEnter");
		if (other.tag == "Spell") {
			elementType otherElement = other.GetComponent<SpellCollision>().elementType; 
			string element = CreateString(elementType, true);
			string elementOpposing = CreateString(otherElement, true);
			WeAreColliding (element, elementOpposing);
		}
		if (other.tag == "Shield") {
			elementType otherElement = other.GetComponent<ShieldElement>().elementType;
			string element = CreateString(elementType, false);
			string elementOpposing = CreateString(otherElement, false);
			WeAreColliding (element, elementOpposing);
		}
		if (other.tag == "PlayerCollision" && time + 1f < Time.time) {
			// score
			if (photonView.isMine) {
				GameManager.instance.player.RemoveSpell(id);
				Debug.Log("Removed MY SPELL");
			}
		}
	}
    /// <summary>
    /// Gets all necessary references.
    /// </summary>
    void Start()
    {
        photonView = this.GetComponent<PhotonView>();
        myTower = this.GetComponent<TowerManager>();

        isMine = photonView.isMine;
    }
    /// <summary>
    /// Gets all necessary references.
    /// </summary>
    void Start()
    {
        photonView = this.GetComponent<PhotonView>();
        myBullet = this.GetComponent<Bullet>();

        isMine = photonView.isMine;
    }
Example #8
0
 void OnJoinedRoom()
 {
     GameObject monster = PhotonNetwork.Instantiate("monsterprefab", Vector3.zero, Quaternion.identity, 0);
     ThirdPersonController controller = monster.GetComponent<ThirdPersonController>();
     myMonsterPv = monster.GetComponent<PhotonView>();
     controller.enabled = true;
 }
Example #9
0
    void Start()
    {
        base.Start();
        nav = this.GetComponent<NavMeshAgent>();
        anim = this.GetComponent<Animator>();
        photonView = this.GetComponent<PhotonView>();
		myPlayerCam = NetworkManager.myChampionGO.transform.FindChild("Main Camera").camera;
		healthBar = prox.gameObject.transform.FindChild ("Progress Bar").gameObject.GetComponent<UISlider>();

        maxHealth = 50;
        health = maxHealth;
        attackDamage = Random.Range(5f, 10f);

        nav.speed = movementSpeed;
        nav.destination = destination;

        // Minion team text indicator
        GetComponentInChildren<TextMesh>().text = team.ToString();
        GetComponentInChildren<TextMesh>().color = (team == 0) ? Color.red : Color.blue;

        //Final destination for any minion is the base of the opponent team
        finalDestination = (team == 0) ? new Vector3(128, 14, 128) : new Vector3(-128, 14, -128);

		if (team == 0) {
			transform.FindChild("Indic").transform.renderer.material.color = Color.red;			
		} else {
			transform.FindChild("Indic").transform.renderer.material.color = Color.blue;
		}
    }
Example #10
0
    public MeshRenderer CannonMesh; // cannon 메쉬

    void Awake ()
    {
        pv = GetComponent<PhotonView>(); 
        pv.observed = this; //PhotonView 의 observed 속성을 이 스크립트로 지정
        pv.synchronization = ViewSynchronization.Unreliable;  //PhotonView 의 observed option 속성설정
        currRot = transform.localRotation;   //회전 초기값 설정
    }
    /// <summary>
    /// Gets all necessary references.
    /// </summary>
    public void Initialize()
    {
        photonView = this.GetComponent<PhotonView>();
        myPlayer = this.GetComponent<PlayerManager>();

        isMine = photonView.isMine;
    }
Example #12
0
		public override void OnEnter ()
		{
			photonView = PhotonView.Get (gameObject.Value);
			photonView.RPC (methodName.Value, targets, parameter1.GetValue (),parameter2.GetValue());
			Finish ();
			
		}
Example #13
0
 // Use this for initialization
 void Start() {
     gameObject.GetComponent<Deplacement>().enabled = false;
     degats = 20;
     power_force = 0;
     power_invin = 0;
     power_soin = 0;
     power_speed = 0;
     Life = 100;
     Faim = 100;
     Soif = 100;
     anim2 = gameObject.GetComponent<Animator>();
     rouge = GameObject.Find("Rouge").GetComponent<Animator>();
     bleu = GameObject.Find("Bleu").GetComponent<Animator>();
     vert = GameObject.Find("Vert").GetComponent<Animator>();
     jaune = GameObject.Find("Jaune").GetComponent<Animator>();
     view = gameObject.GetComponent<PhotonView>();
     if (view.isMine)
     {
         myCamera.SetActive(true);
     }
     else
     {
         gameObject.GetComponent<Joueur>().enabled = false;
         gameObject.GetComponentInChildren<AudioListener>().enabled = false;
         gameObject.GetComponentInChildren<Camera>().enabled = false;
         gameObject.GetComponentInChildren<Camera>().enabled = false;
         gameObject.GetComponent<Deplacement>().enabled = false;
         gameObject.GetComponent<Pause>().enabled = false;
     }
 }
	void Awake()
    {
        cannon = (GameObject)Resources.Load("Cannon");
        fireSfx = Resources.Load<AudioClip>("CannonFire");
        sfx = GetComponent<AudioSource>();
        pv = GetComponent<PhotonView>();
    }
Example #15
0
    public void LookForCharacter(string name)
    {
        GameObject character = GameObject.Find(name);

        characterScript = character.GetComponent<Character>();
        characterPV = character.GetComponent<PhotonView>();
    }
Example #16
0
 void Awake()
 {
     logger = Logger.GetInstance();
     jobsData = Jobs.GetInstance();
     ressources = Ressources.GetInstance();
     pView = GameObject.FindWithTag("Attackers").GetComponent<PhotonView>();
 }
Example #17
0
	void Start () {
	//初期設定
		Screen.sleepTimeout = SleepTimeout.NeverSleep;

		myTeamID = 0;
		loadOnce = false;
		scenePV  = PhotonView.Get (this.gameObject);
		tagTimer = 0f;
		sendOnce = false;
		tc1tmp   = variableManage.team1Rest;
		tc2tmp   = variableManage.team2Rest;
		bc1tmp   = variableManage.base1Rest;
		bc2tmp   = variableManage.base2Rest;

		standardTime = "";
		serverTime   = "";
		countStart   = false;
		shiftTimer   = 0f;

	//PhotonRealtimeのサーバーへ接続、ロビーへ入室
		PhotonNetwork.ConnectUsingSettings(null);

	//スタート地点計算
		Vector2 rndPos = Vector2.zero;
		while(true){
			rndPos = Random.insideUnitCircle * 150f;
			if(rndPos.x < -20f){
				if(rndPos.y >20f){
					break;
				}
			}
		}
		myStartPos = new Vector2 ( (592f + rndPos.x), (-592 + rndPos.y) );
	}
Example #18
0
	public void Awake()
	{
		time = Time.time;
		Loaded = false;
		mGen = GetComponent<MapGeneration> (); //new MapGeneration();
		pFind = GetComponent<AStar> ();
		photonView = GetComponent<PhotonView> ();
		seed = 0;
		if (PhotonNetwork.isMasterClient) {
			seed = Random.seed;
			for (int i = -4; i <= 4; ++i) {
				for(int j = -4; j <= 4; ++j){
					mGen.GenerateBlock (i, j, seed, 0, 0);
				}
			}
			mGen.CreateGrid(0, 0);
			Loaded = true;	
			lastX = 0;
			lastY = 0;
		}
		
		// in case we started this demo with the wrong scene being active, simply load the menu scene
		if (!PhotonNetwork.connected)
		{
			Application.LoadLevel(Menu.SceneNameMenu);
			return;
		}
		// we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate
		playerObject = PhotonNetwork.Instantiate(this.playerPrefab.name, transform.position, Quaternion.identity, 0);
		playerController = playerObject.GetComponent<ThirdPersonController> ();
	}
Example #19
0
 void Awake()
 {
     jobs = Jobs.GetInstance();
     enemiesData = Jobs.GetEnemies();
     logger = Logger.GetInstance();
     pView = GameObject.FindWithTag("Raiders").GetComponent<PhotonView>();
 }
Example #20
0
    void Awake()
    {

        anim = GetComponent<Animator>();
        photonView = GetComponent<PhotonView>();
        navMeshSpeed = GetComponent<NavMeshAgent>().speed;
    }
    // Use this for initialization
    void Start()
    {
        if (photonView == null)
            photonView = GetComponent<PhotonView>();

        sendFrame = 60 / PhotonNetwork.sendRate;
    }
Example #22
0
	// Use this for initialization
	void Start () 
	{
		bmr = FindObjectOfType<BulletManager>();
		pv = GetComponent<PhotonView>();
		baseCD = BulletCD;
        //canShoot = GetComponent<RocketControl>().canMove;
	}
	/*---------------------------------------------------- AWAKE & UPDATE ----------------------------------------------------*/

	void Awake()
	{
		gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
		photonView = GetComponent<PhotonView>();

		teleporterAnimator = GetComponent<Animator>();
	}
Example #24
0
 void Start()
 {
     m_CharacterController = GetComponent<CharacterController>();
     m_Animator = GetComponent<Animator>();
     m_PhotonView = GetComponent<PhotonView>();
     m_TransformView = GetComponent<PhotonTransformView>();
 }
 void Start()
 {
     photonView = gameObject.GetComponent<PhotonView>();
     playerHealth = GetComponent<Health>().health;
     anim = GetComponent<Animator>();
     
 }
	void Awake ()
    {
        pv = GetComponent<PhotonView>();
        CreateTank();
        PhotonNetwork.isMessageQueueRunning = true;
        GetConnectPlayerCount();
    }
Example #27
0
    public void ResultOn()
    {
        ResultActvie = true;
        Ending.SetActive (false);
        Canvas.GetComponent<Animator>().SetTrigger("OnResultStart");

        AudioManager.Instance.PlayBGM(win ? "resultclearbgm" : "resultfailbgm", 0.5f);

        GameObject.Find ("MyResultText").GetComponent<Text> ().text =
            (GameManager.instance.CorrectAnswerNum + GameManager.instance.IncorrectAnswerNum).ToString ()
                + "もん中、\n" + GameManager.instance.CorrectAnswerNum.ToString() + "もんせいかい!";

        myPv = this.GetComponent<PhotonView>();

        memberCorrectAnswerNum = new Dictionary<string, int>();
        memberInCorrectAnswerNum = new Dictionary<string, int>();
        myPv.RPC ("SetMemberAnswerNum", PhotonTargets.All, GameManager.instance.name, GameManager.instance.CorrectAnswerNum, GameManager.instance.IncorrectAnswerNum);

        GameObject.Find("HpGuage").transform.localScale = new Vector3(1, (GameManager.instance.BossHp > GameManager.instance.Score)? (float)(GameManager.instance.BossHp - GameManager.instance.Score) / GameManager.instance.BossHp : 0, 1);

        if (win) {
            GameObject.Find ("BackGround").GetComponent<Image> ().sprite = backgroundWin;
            GameObject.Find ("Title").GetComponent<Image> ().sprite = titleWin;
            GameObject.Find ("Enemy").GetComponent<Image> ().sprite = enemyWin[GameManager.instance.SelectLevel];
        } else {
            GameObject.Find ("BackGround").GetComponent<Image> ().sprite = backgroundLose;
            GameObject.Find ("Title").GetComponent<Image> ().sprite = titleLose;
            GameObject.Find ("Enemy").GetComponent<Image> ().sprite = enemyLose[GameManager.instance.SelectLevel];
        }
    }
	void Start() {
		hitFlag = false;
		hitFlagTimer = 0f;
		destroyTimer = 0f;
		myPV = PhotonView.Get(this.gameObject);
		myRigid = GetComponent<Rigidbody>();
	}
Example #29
0
		public override void OnEnter ()
		{
			photonView = PhotonView.Get (gameObject.Value);
			photonView.RPC ("SetTrigger", targets, trigger.Value);
			Finish ();
			
		}
Example #30
0
	void Awake () {
		// 컴포넌트 할당
		rbody = GetComponent<Rigidbody> ();
		tr = GetComponent<Transform> ();

		// PhotonView 컴포넌트 할당
		pv = GetComponent<PhotonView> ();
		// 데이터 전송 타입을 설정
		pv.synchronization = ViewSynchronization.UnreliableOnChange;

		// PhotonView Observed Components 속성에 TankMove 스크립트를 연결
		pv.ObservedComponents [0] = this;

		// PhotonView가 자신의 탱크일 경우
		if (pv.isMine) {
			// 메인 카메라에 추가된 SmoothFollow 스크립트에 추적 대상을 연결
			Camera.main.GetComponent<SmoothFollow> ().target = camPivot;
			// Rigidbody의 무게중심을 낮게 설정
			rbody.centerOfMass = new Vector3 (0.0f, -0.5f, 0.0f);
		} else {
			// 원격 네트워크 플레이어의 탱크는 물리력을 이용하지 않음
			rbody.isKinematic = true;
		}

		// 원격 탱크의 위치 및 회전 값을 처리할 변수의 초깃값 설정
		currPos = tr.position;
		currRot = tr.rotation;
	}
Example #31
0
 // Use this for initialization
 void Start()
 {
     view = GetComponent <PhotonView>();
     OnJoinedRoom();
 }
 // Start is called before the first frame update
 void Start()
 {
     m_PhotonView = GetComponent <PhotonView>();
     WhiteBoard.OnClickWhiteBoardMoveButton.Subscribe(go => OnClickWhiteBoardMoveButtonForAllWhiteBoard(go)).AddTo(this);
     OnClickWhiteBoardMoveActionPanel.Subscribe(_ => ClickWhiteBoardMoveActionPanelForAllWhiteBoard()).AddTo(this);
 }
Example #33
0
    // Update is called once per frame
    void Fire()
    {
        if (weaponData == null)
        {
            weaponData = gameObject.GetComponentInChildren <WeaponData>();
            weaponType = weaponData.weaponType;
            if (weaponData == null)
            {
                Debug.Log("Couldn't Find WeaponData in our children");
            }
            return;
        }


        if (coolDown > 0 || animator.GetBool("IsDead") == true)
        {
            if (animator.GetBool("IsDead") == true)
            {
                Debug.Log("Dead People Can't Shoot!");
            }
            return;
        }

        Ray       ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
        Transform hitTransform;
        Vector3   hitPoint;

        hitTransform = FindClosestHitObject(ray, out hitPoint);


        if (hitTransform.transform != null)
        {
            Debug.Log("We Hit: " + hitTransform.name);

            //Do special effect at hit location

            Health h = hitTransform.GetComponent <Health>();

            //Search through hirarchy of OBJ parents to find if it has a Health component
            while (h == null && hitTransform.parent)
            {
                hitTransform = hitTransform.parent;
                h            = hitTransform.GetComponent <Health>();
            }

            //once we find health
            if (h != null)
            {
                PhotonView PhotonView = h.GetComponent <PhotonView>();
                if (PhotonView == null)
                {
                    Debug.Log("There is no PhotonView");
                }
                else
                {
                    h.GetComponent <PhotonView>().RPC("TakeDamage", RpcTarget.All, currentWepDmg, h.GetComponent <PhotonView>().gameObject.tag);
                }
            }
        }
        if (fxManager != null)
        {
            DoGunFX(hitPoint, weaponType);
        }
        else
        {
            //We didnt hit anything but empty space, lets do FX anyways
            if (fxManager != null)
            {
                hitPoint = Camera.main.transform.position + (Camera.main.transform.forward * 100f);
                DoGunFX(hitPoint, weaponType);
            }
        }
        coolDown = weaponData.fireRate;
    }
Example #34
0
 private void RPC_ParentChild(int child, int parent)
 {
     ParentChild(PhotonView.Find(child).gameObject, PhotonView.Find(parent).gameObject);
 }
Example #35
0
 void Start()
 {
     pv = GameObject.Find("Canvas").GetComponent <PhotonView>();
 }
Example #36
0
 // Start is called before the first frame update
 void Start()
 {
     PV = GetComponent <PhotonView>();
 }
Example #37
0
    void updateMe(int senderID)
    {
        //********** ADDING US ON THE BOARD

        //We get the ID of the new player who needs to be updated
        PhotonPlayer sender = PhotonPlayer.Find(senderID);

        //We get our own ID
        PhotonView myView = PhotonView.Get(this);
        int        myID   = myView.owner.ID;

        //We get our basic stats
        string myTag = "";

        int  iA    = 0;
        bool doneA = false;

        //Retrieving our gamertag

        /*while(iA<4 && doneA==false)
         * {
         *      if(myTeam=="Blue")
         *      {
         *              myTag = playerTagsBlue[iA];
         *      }
         *      else
         *      {
         *              myTag = playerTagsRed[iA];
         *      }
         *      iA++;
         * }*/

        myTag = PlayerPrefs.GetString("Gamertag");

        //We pack all of this
        string myTagTeam = myID.ToString() + ";" + myTag + ";" + myTeam;

        //We add ourself on his board
        myView.RPC("addOnBoard", PhotonTargets.All, myTagTeam);


        //********* UPDATING OUR STATS ON THE BOARD
        //We get our stats
        int myKill   = 0;
        int myAssist = 0;
        int myDeath  = 0;

        int  iU    = 0;
        bool doneU = false;

        //Retrieving our score

        /*while(iU<4 && doneU==false)
         * {
         *      if(myTeam=="Blue")
         *      {
         *              if(playerScoreBlue[iU,0]==myID)
         *              {
         *                      myKill = playerScoreBlue[iU,1];
         *                      myAssist = playerScoreBlue[iU,2];
         *                      myDeath = playerScoreBlue[iU,3];
         *                      doneU=true;
         *              }
         *      }
         *      else {
         *              if(playerScoreRed[iU,0]==myID)
         *              {
         *                      myKill = playerScoreRed[iU,1];
         *                      myAssist = playerScoreRed[iU,2];
         *                      myDeath = playerScoreRed[iU,3];
         *                      doneU=true;
         *              }
         *      }
         *      iU++;
         * }*/

        while (iU < 4 && doneU == false)
        {
            if (myTeam == "Blue")
            {
                if (playerScoreBlue[4 * iU] == myID)
                {
                    myKill   = playerScoreBlue[4 * iU + 1];
                    myAssist = playerScoreBlue[4 * iU + 2];
                    myDeath  = playerScoreBlue[4 * iU + 3];
                    doneU    = true;
                }
            }
            else
            {
                if (playerScoreRed[4 * iU] == myID)
                {
                    myKill   = playerScoreRed[4 * iU + 1];
                    myAssist = playerScoreRed[4 * iU + 2];
                    myDeath  = playerScoreRed[4 * iU + 3];
                    doneU    = true;
                }
            }
            iU++;
        }

        //We pack this into a string
        string myTagScore = myID.ToString() + ";" + myKill.ToString() + ";" + myAssist.ToString() + ";" + myDeath.ToString();

        myView.RPC("updateScore", PhotonTargets.All, myTagScore);
    }
Example #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PhotonMessageInfo"/> class.
 /// To create an empty messageinfo only!
 /// </summary>
 public PhotonMessageInfo()
 {
     this.sender     = PhotonNetwork.player;
     this.timeInt    = (int)(PhotonNetwork.time * 1000);
     this.photonView = null;
 }
 void Start()
 {
     this.photonView = this.GetComponent <PhotonView>();
 }
Example #40
0
 protected override void Awake()
 {
     base.Awake();
     photonView = GetComponent <PhotonView>();
 }
 public void OnOwnershipTransfered(PhotonView targetView, Player previousOwner)
 {
     throw new System.NotImplementedException();
 }
 public void OnOwnershipRequest(PhotonView targetView, Player requestingPlayer)
 {
     targetView.TransferOwnership(requestingPlayer);
 }
Example #43
0
    void addOnBoard(string ident)
    {
        PhotonView photonView = PhotonView.Get(this);

        //We take back his infos
        string[] playerSet = ident.Split(';');

        int    playerID   = int.Parse(playerSet[0]);
        string playerTag  = playerSet[1];
        string playerTeam = playerSet[2];

        //We look for an empty place on the board
        int  i    = 0;
        bool done = false;

        /*while(i<4 && done==false)
         * {
         *      if(playerScoreBlue[i,0]==playerID || playerScoreRed[i,0]==playerID)
         *              done=true;
         *
         *      if(playerScoreBlue[i,0]==0 && playerTeam=="Blue" && done==false)
         *      {
         *              playerScoreBlue[i,0]=playerID;
         *              playerScoreBlue[i,1]=0;
         *              playerScoreBlue[i,2]=0;
         *              playerScoreBlue[i,3]=0;
         *
         *              playerTagsBlue[i]=playerTag;
         *              Debug.Log("Added player " + playerID + " on team " + playerTeam);
         *              done=true;
         *      }
         *      if(playerScoreRed[i,0]==0 && playerTeam=="Red" && done==false)
         *      {
         *              playerScoreRed[i,0]=playerID;
         *              playerScoreRed[i,1]=0;
         *              playerScoreRed[i,2]=0;
         *              playerScoreRed[i,3]=0;
         *
         *              playerTagsRed[i]=playerTag;
         *              Debug.Log("Added player " + playerID + " on team " + playerTeam);
         *              done=true;
         *      }
         *      i++;
         * }*/

        while (i < 4 && done == false)
        {
            if (playerScoreBlue[4 * i] == playerID || playerScoreRed[4 * i] == playerID)
            {
                done = true;
            }

            if (playerScoreBlue[4 * i] == 0 && playerTeam == "Blue" && done == false)
            {
                playerScoreBlue[4 * i]     = playerID;
                playerScoreBlue[4 * i + 1] = 0;
                playerScoreBlue[4 * i + 2] = 0;
                playerScoreBlue[4 * i + 3] = 0;

                playerTagsBlue[i] = playerTag;
                Debug.Log("Added player " + playerID + " on team " + playerTeam);
                done = true;
            }
            if (playerScoreRed[4 * i] == 0 && playerTeam == "Red" && done == false)
            {
                playerScoreRed[4 * i]     = playerID;
                playerScoreRed[4 * i + 1] = 0;
                playerScoreRed[4 * i + 2] = 0;
                playerScoreRed[4 * i + 3] = 0;

                playerTagsRed[i] = playerTag;
                Debug.Log("Added player " + playerID + " on team " + playerTeam);
                done = true;
            }
            i++;
        }

        //if (photonView.isMine)
        //photonView.RPC("addOnBoard", PhotonTargets.Others, ident);
    }
Example #44
0
 public void RegisterOwner(GamePlayerController controller)
 {
     Owner           = controller;
     OwnerPhotonView = Owner.gameObject.GetComponent <PhotonView>();
 }
Example #45
0
 void Start()
 {
     //GetComponet
     view = this.gameObject.GetComponent <PhotonView>();
 }
        public static GameObject CreatePrefabCopy(GameObject prefab)
        {
            string lastPath = DatabasePhoton.Load().lastPath;

            //if (string.IsNullOrEmpty(lastPath))
            //{
            lastPath = GetPath(lastPath);
            //}
            if (string.IsNullOrEmpty(lastPath))
            {
                Debug.LogWarning("Nothing was created!");
                //EditorUtility.DisplayDialog("Could not create Prefab", "Prefab Path folder has not been defined", "Ok");
                return(null);
            }

            string prefabName = lastPath + "/" + prefab.name + ".prefab";

            DatabasePhoton.Load().lastPath = lastPath;

            //Object prefab2 = PrefabUtility.CreateEmptyPrefab(prefabName);
            //GameObject newPrefab = PrefabUtility.ReplacePrefab(prefab, prefab2, ReplacePrefabOptions.Default);
            //GameObject newPrefab = PrefabUtility.SaveAsPrefabAsset(new GameObject(prefab.name), lastPath);
            GameObject newPrefab = PrefabUtility.SaveAsPrefabAsset(prefab, lastPath);

            //DestroyImmediate(go);

            if (!DatabasePhoton.Load().prefabs.Contains(newPrefab))
            {
                DatabasePhoton.Load().prefabs.Add(newPrefab);

                /*SerializedObject so = new SerializedObject(Load());
                 * so.ApplyModifiedProperties();
                 * so.Update();*/
            }

            CharacterNetwork chnet     = newPrefab.GetComponent <CharacterNetwork>();
            Character        character = newPrefab.GetComponent <Character>();

#if PHOTON_UNITY_NETWORKING
            PhotonView pview = newPrefab.GetPhotonView();

            if (pview == null)
            {
                pview = newPrefab.AddComponent <PhotonView>();
            }

            if (chnet == null && character != null)
            {
                chnet = newPrefab.AddComponent <CharacterNetwork>();
            }

            if (pview.Synchronization == ViewSynchronization.Off)
            {
                pview.Synchronization = ViewSynchronization.UnreliableOnChange;
            }

            if (chnet != null && !pview.ObservedComponents.Contains(chnet))
            {
                pview.ObservedComponents.Add(chnet);
            }
#endif
            return(newPrefab);
        }
    private IEnumerator updateSkillsInSKillBar()
    {
        while (true)
        {
            yield return(new WaitForSeconds(0.2f));

            if (!initialized)
            {
                PlayerManager[] players = FindObjectsOfType <PlayerManager>();
                foreach (PlayerManager player in players)
                {
                    PhotonView view = player.getView();
                    if (view.isMine)
                    {
                        this.player   = player.transform.gameObject;
                        playerManager = player;
                        goldCounterTextObject.GetComponent <GoldCounterManager>().playerManager = player;
                    }
                }
                if (this.player == null)
                {
                    continue;
                }

                GameObject skillCDIconPrototype = (GameObject)Resources.Load("SkillCDIcon");

                Skill[] skills = this.player.GetComponents <Skill>();
                foreach (Skill skill in skills)
                {
                    GameObject skillCDIcon = Instantiate(skillCDIconPrototype);
                    skillCDIcon.transform.SetParent(skillBar.transform);
                    SkillCDIconManager iconManager = skillCDIcon.GetComponent <SkillCDIconManager>();
                    iconManager.skill = skill;
                    iconManager.setSprite(skill.skillIcon);
                }

                initialized = true;
            }

            SkillCDIconManager[] skillCDIcons = skillBar.GetComponentsInChildren <SkillCDIconManager>();
            foreach (SkillCDIconManager skillCDIcon in skillCDIcons)
            {
                Skill skill = skillCDIcon.skill;
                if (skill.isOnCD() || playerManager.gold < skill.goldCost)
                {
                    if (skill.isOnCD())
                    {
                        float elapsedTime = Time.time - skill.getLastFired();
                        int   cdCount     = Mathf.RoundToInt(skill.cooldown - elapsedTime);
                        skillCDIcon.dim();
                        skillCDIcon.setText("" + cdCount);
                    }
                    else
                    {
                        skillCDIcon.dim();
                        skillCDIcon.setText("G");
                    }
                }
                else
                {
                    skillCDIcon.brighten();
                    skillCDIcon.setText("");
                }
            }
        }
    }
    public void OnEvent(EventData photonEvent)
    {
        byte eventCode = photonEvent.Code;

        object[] data   = null;
        Cell     cell   = null;
        int      viewId = -1;

        switch (eventCode)
        {
        case GameEvents.IncrementTurn:
            Game.Instance.IncrementTurn();
            if (Game.Instance.IsLocalPlayersTurn())
            {
                Player player = Game.Instance.GetCurrentPlayer();
                foreach (POI poi in Game.Instance.activePOIs)
                {
                    ((MonoBehaviourPun)poi).photonView.TransferOwnership(player.ActorNumber);
                }
            }
            break;

        case GameEvents.FindFiremanAndAssociate:
            //first arg is player's ActorNumber
            //second arg is fireman GameObject's viewID
            data = (object[])photonEvent.CustomData;
            int actorNumber = (int)data[0];
            viewId = (int)data[1];
            GameObject firemanGo = PhotonView.Find(viewId).gameObject;
            FireMan    fireman   = firemanGo.GetComponent <FireMan>();
            Game.Instance.AddFiremanAndAssociate(fireman, actorNumber);
            break;

        case GameEvents.SetCellStatus:
            data = (object[])photonEvent.CustomData;

            Game.Instance.GetCell((int)data[0], (int)data[1], ref cell);

            CellStatus status = (CellStatus)data[2];
            cell.SetStatus(status);
            break;

        case GameEvents.DamageWall:
            data = (object[])photonEvent.CustomData;

            Game.Instance.GetCell((int)data[0], (int)data[1], ref cell);

            Wall wall = (Wall)cell.GetEdge((Direction)data[2]);

            wall.Damage();
            break;

        case GameEvents.SetDoorStatus:
            data = (object[])photonEvent.CustomData;

            Game.Instance.GetCell((int)data[0], (int)data[1], ref cell);

            Door door = (Door)cell.GetEdge((Direction)data[2]);

            door.SetStatus((DoorStatus)data[3]);
            break;

        case GameEvents.FindPOI:
            data   = (object[])photonEvent.CustomData;
            viewId = (int)data[0];
            GameObject poiGo = PhotonView.Find(viewId).gameObject;
            if (poiGo.GetComponent <Victim>() != null)
            {
                Game.Instance.inactivePOIs.Add(poiGo.GetComponent <Victim>());
            }
            else
            {
                Game.Instance.inactivePOIs.Add(poiGo.GetComponent <FalseAlarm>());
            }
            break;

        case GameEvents.ActivatePOIEvent:
            data = (object[])photonEvent.CustomData;
            int index = (int)data[0];

            if (index > Game.Instance.inactivePOIs.Count)
            {
                Debug.LogError("it seems that the inactivePOIs arraylist is out of sync");
                index = 0;
            }
            Game.Instance.GetCell((int)data[1], (int)data[2], ref cell);
            Game.Instance.ActivatePOI(index, cell);
            break;

        case GameEvents.TransferOwnership:

            break;

        default:
            Debug.Log("event code not implemented: " + eventCode);
            break;
        }
    }
Example #49
0
 private void Start()
 {
     photonView = GetComponent <PhotonView>();
 }
Example #50
0
    private PhotonView myPhotonView;     //create this photonView Object

    //***********************************************************************************
    //*                        Initilization for Event Handler                                *
    //***********************************************************************************

    void OnJoinedRoom()
    {
        myPhotonView = this.GetComponent <PhotonView>();       //reference photonview in this gameobject
    }
Example #51
0
 private void OnTriggerStay(Collider other)
 {
     if (this.active_me)
     {
         if (!this.currentHitsII.Contains(other.gameObject))
         {
             this.currentHitsII.Add(other.gameObject);
             this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().startShake(0.1f, 0.1f, 0.95f);
             if (other.gameObject.transform.root.gameObject.tag == "titan")
             {
                 GameObject obj2;
                 this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.GetComponent <HERO>().slashHit.Play();
                 if (IN_GAME_MAIN_CAMERA.gametype != GAMETYPE.SINGLE)
                 {
                     obj2 = PhotonNetwork.Instantiate("hitMeat", base.transform.position, Quaternion.Euler(270f, 0f, 0f), 0);
                 }
                 else
                 {
                     obj2 = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("hitMeat"));
                 }
                 obj2.transform.position = base.transform.position;
                 base.transform.root.GetComponent <HERO>().useBlade(0);
             }
         }
         if (other.gameObject.tag == "playerHitbox")
         {
             if (LevelInfo.getInfo(FengGameManagerMKII.level).pvp)
             {
                 float b = 1f - (Vector3.Distance(other.gameObject.transform.position, base.transform.position) * 0.05f);
                 b = Mathf.Min(1f, b);
                 HitBox component = other.gameObject.GetComponent <HitBox>();
                 if ((((component != null) && (component.transform.root != null)) && (component.transform.root.GetComponent <HERO>().myTeam != this.myTeam)) && !component.transform.root.GetComponent <HERO>().isInvincible())
                 {
                     if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                     {
                         if (!component.transform.root.GetComponent <HERO>().isGrabbed)
                         {
                             Vector3 vector = component.transform.root.transform.position - base.transform.position;
                             component.transform.root.GetComponent <HERO>().die((Vector3)(((vector.normalized * b) * 1000f) + (Vector3.up * 50f)), false);
                         }
                     }
                     else if (((IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.MULTIPLAYER) && !component.transform.root.GetComponent <HERO>().HasDied()) && !component.transform.root.GetComponent <HERO>().isGrabbed)
                     {
                         component.transform.root.GetComponent <HERO>().markDie();
                         object[] parameters = new object[5];
                         Vector3  vector2    = component.transform.root.position - base.transform.position;
                         parameters[0] = (Vector3)(((vector2.normalized * b) * 1000f) + (Vector3.up * 50f));
                         parameters[1] = false;
                         parameters[2] = base.transform.root.gameObject.GetPhotonView().viewID;
                         parameters[3] = PhotonView.Find(base.transform.root.gameObject.GetPhotonView().viewID).owner.customProperties[PhotonPlayerProperty.name];
                         parameters[4] = false;
                         component.transform.root.GetComponent <HERO>().photonView.RPC("netDie", PhotonTargets.All, parameters);
                     }
                 }
             }
         }
         else if (other.gameObject.tag == "titanneck")
         {
             HitBox item = other.gameObject.GetComponent <HitBox>();
             if (((item != null) && this.checkIfBehind(item.transform.root.gameObject)) && !this.currentHits.Contains(item))
             {
                 item.hitPosition = (Vector3)((base.transform.position + item.transform.position) * 0.5f);
                 this.currentHits.Add(item);
                 this.meatDie.Play();
                 if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                 {
                     if ((item.transform.root.GetComponent <TITAN>() != null) && !item.transform.root.GetComponent <TITAN>().hasDie)
                     {
                         Vector3 vector3 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                         int     num2    = (int)((vector3.magnitude * 10f) * this.scoreMulti);
                         num2 = Mathf.Max(10, num2);
                         if (PlayerPrefs.HasKey("EnableSS") && (PlayerPrefs.GetInt("EnableSS") == 1))
                         {
                             GameObject.Find("MainCamera").GetComponent <IN_GAME_MAIN_CAMERA>().startSnapShot2(item.transform.position, num2, item.transform.root.gameObject, 0.02f);
                         }
                         item.transform.root.GetComponent <TITAN>().die();
                         this.napeMeat(this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity, item.transform.root);
                         GameObject.Find("MultiplayerManager").GetComponent <FengGameManagerMKII>().netShowDamage(num2);
                         GameObject.Find("MultiplayerManager").GetComponent <FengGameManagerMKII>().playerKillInfoSingleUpdate(num2);
                     }
                 }
                 else if (!PhotonNetwork.isMasterClient)
                 {
                     if (item.transform.root.GetComponent <TITAN>() != null)
                     {
                         if (!item.transform.root.GetComponent <TITAN>().hasDie)
                         {
                             Vector3 vector4 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                             int     num3    = (int)((vector4.magnitude * 10f) * this.scoreMulti);
                             num3 = Mathf.Max(10, num3);
                             if (PlayerPrefs.HasKey("EnableSS") && (PlayerPrefs.GetInt("EnableSS") == 1))
                             {
                                 GameObject.Find("MainCamera").GetComponent <IN_GAME_MAIN_CAMERA>().startSnapShot2(item.transform.position, num3, item.transform.root.gameObject, 0.02f);
                                 item.transform.root.GetComponent <TITAN>().asClientLookTarget = false;
                             }
                             object[] objArray2 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID, num3 };
                             item.transform.root.GetComponent <TITAN>().photonView.RPC("titanGetHit", item.transform.root.GetComponent <TITAN>().photonView.owner, objArray2);
                         }
                     }
                     else if (item.transform.root.GetComponent <FEMALE_TITAN>() != null)
                     {
                         base.transform.root.GetComponent <HERO>().useBlade(0x7fffffff);
                         Vector3 vector5 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                         int     num4    = (int)((vector5.magnitude * 10f) * this.scoreMulti);
                         num4 = Mathf.Max(10, num4);
                         if (!item.transform.root.GetComponent <FEMALE_TITAN>().hasDie)
                         {
                             object[] objArray3 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID, num4 };
                             item.transform.root.GetComponent <FEMALE_TITAN>().photonView.RPC("titanGetHit", item.transform.root.GetComponent <FEMALE_TITAN>().photonView.owner, objArray3);
                         }
                     }
                     else if (item.transform.root.GetComponent <COLOSSAL_TITAN>() != null)
                     {
                         base.transform.root.GetComponent <HERO>().useBlade(0x7fffffff);
                         if (!item.transform.root.GetComponent <COLOSSAL_TITAN>().hasDie)
                         {
                             Vector3 vector6 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                             int     num5    = (int)((vector6.magnitude * 10f) * this.scoreMulti);
                             num5 = Mathf.Max(10, num5);
                             object[] objArray4 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID, num5 };
                             item.transform.root.GetComponent <COLOSSAL_TITAN>().photonView.RPC("titanGetHit", item.transform.root.GetComponent <COLOSSAL_TITAN>().photonView.owner, objArray4);
                         }
                     }
                 }
                 else if (item.transform.root.GetComponent <TITAN>() != null)
                 {
                     if (!item.transform.root.GetComponent <TITAN>().hasDie)
                     {
                         Vector3 vector7 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                         int     num6    = (int)((vector7.magnitude * 10f) * this.scoreMulti);
                         num6 = Mathf.Max(10, num6);
                         if (PlayerPrefs.HasKey("EnableSS") && (PlayerPrefs.GetInt("EnableSS") == 1))
                         {
                             GameObject.Find("MainCamera").GetComponent <IN_GAME_MAIN_CAMERA>().startSnapShot2(item.transform.position, num6, item.transform.root.gameObject, 0.02f);
                         }
                         item.transform.root.GetComponent <TITAN>().titanGetHit(base.transform.root.gameObject.GetPhotonView().viewID, num6);
                     }
                 }
                 else if (item.transform.root.GetComponent <FEMALE_TITAN>() != null)
                 {
                     base.transform.root.GetComponent <HERO>().useBlade(0x7fffffff);
                     if (!item.transform.root.GetComponent <FEMALE_TITAN>().hasDie)
                     {
                         Vector3 vector8 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                         int     num7    = (int)((vector8.magnitude * 10f) * this.scoreMulti);
                         num7 = Mathf.Max(10, num7);
                         if (PlayerPrefs.HasKey("EnableSS") && (PlayerPrefs.GetInt("EnableSS") == 1))
                         {
                             GameObject.Find("MainCamera").GetComponent <IN_GAME_MAIN_CAMERA>().startSnapShot2(item.transform.position, num7, null, 0.02f);
                         }
                         item.transform.root.GetComponent <FEMALE_TITAN>().titanGetHit(base.transform.root.gameObject.GetPhotonView().viewID, num7);
                     }
                 }
                 else if (item.transform.root.GetComponent <COLOSSAL_TITAN>() != null)
                 {
                     base.transform.root.GetComponent <HERO>().useBlade(0x7fffffff);
                     if (!item.transform.root.GetComponent <COLOSSAL_TITAN>().hasDie)
                     {
                         Vector3 vector9 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - item.transform.root.rigidbody.velocity;
                         int     num8    = (int)((vector9.magnitude * 10f) * this.scoreMulti);
                         num8 = Mathf.Max(10, num8);
                         if (PlayerPrefs.HasKey("EnableSS") && (PlayerPrefs.GetInt("EnableSS") == 1))
                         {
                             GameObject.Find("MainCamera").GetComponent <IN_GAME_MAIN_CAMERA>().startSnapShot2(item.transform.position, num8, null, 0.02f);
                         }
                         item.transform.root.GetComponent <COLOSSAL_TITAN>().titanGetHit(base.transform.root.gameObject.GetPhotonView().viewID, num8);
                     }
                 }
                 this.showCriticalHitFX();
             }
         }
         else if (other.gameObject.tag == "titaneye")
         {
             if (!this.currentHits.Contains(other.gameObject))
             {
                 this.currentHits.Add(other.gameObject);
                 GameObject gameObject = other.gameObject.transform.root.gameObject;
                 if (gameObject.GetComponent <FEMALE_TITAN>() != null)
                 {
                     if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                     {
                         if (!gameObject.GetComponent <FEMALE_TITAN>().hasDie)
                         {
                             gameObject.GetComponent <FEMALE_TITAN>().hitEye();
                         }
                     }
                     else if (!PhotonNetwork.isMasterClient)
                     {
                         if (!gameObject.GetComponent <FEMALE_TITAN>().hasDie)
                         {
                             object[] objArray5 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID };
                             gameObject.GetComponent <FEMALE_TITAN>().photonView.RPC("hitEyeRPC", PhotonTargets.MasterClient, objArray5);
                         }
                     }
                     else if (!gameObject.GetComponent <FEMALE_TITAN>().hasDie)
                     {
                         gameObject.GetComponent <FEMALE_TITAN>().hitEyeRPC(base.transform.root.gameObject.GetPhotonView().viewID);
                     }
                 }
                 else if (gameObject.GetComponent <TITAN>().abnormalType != AbnormalType.TYPE_CRAWLER)
                 {
                     if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                     {
                         if (!gameObject.GetComponent <TITAN>().hasDie)
                         {
                             gameObject.GetComponent <TITAN>().hitEye();
                         }
                     }
                     else if (!PhotonNetwork.isMasterClient)
                     {
                         if (!gameObject.GetComponent <TITAN>().hasDie)
                         {
                             object[] objArray6 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID };
                             gameObject.GetComponent <TITAN>().photonView.RPC("hitEyeRPC", PhotonTargets.MasterClient, objArray6);
                         }
                     }
                     else if (!gameObject.GetComponent <TITAN>().hasDie)
                     {
                         gameObject.GetComponent <TITAN>().hitEyeRPC(base.transform.root.gameObject.GetPhotonView().viewID);
                     }
                     this.showCriticalHitFX();
                 }
             }
         }
         else if ((other.gameObject.tag == "titanankle") && !this.currentHits.Contains(other.gameObject))
         {
             this.currentHits.Add(other.gameObject);
             GameObject obj4     = other.gameObject.transform.root.gameObject;
             Vector3    vector10 = this.currentCamera.GetComponent <IN_GAME_MAIN_CAMERA>().main_object.rigidbody.velocity - obj4.rigidbody.velocity;
             int        num9     = (int)((vector10.magnitude * 10f) * this.scoreMulti);
             num9 = Mathf.Max(10, num9);
             if ((obj4.GetComponent <TITAN>() != null) && (obj4.GetComponent <TITAN>().abnormalType != AbnormalType.TYPE_CRAWLER))
             {
                 if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                 {
                     if (!obj4.GetComponent <TITAN>().hasDie)
                     {
                         obj4.GetComponent <TITAN>().hitAnkle();
                     }
                 }
                 else
                 {
                     if (!PhotonNetwork.isMasterClient)
                     {
                         if (!obj4.GetComponent <TITAN>().hasDie)
                         {
                             object[] objArray7 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID };
                             obj4.GetComponent <TITAN>().photonView.RPC("hitAnkleRPC", PhotonTargets.MasterClient, objArray7);
                         }
                     }
                     else if (!obj4.GetComponent <TITAN>().hasDie)
                     {
                         obj4.GetComponent <TITAN>().hitAnkle();
                     }
                     this.showCriticalHitFX();
                 }
             }
             else if (obj4.GetComponent <FEMALE_TITAN>() != null)
             {
                 if (IN_GAME_MAIN_CAMERA.gametype == GAMETYPE.SINGLE)
                 {
                     if (other.gameObject.name == "ankleR")
                     {
                         if ((obj4.GetComponent <FEMALE_TITAN>() != null) && !obj4.GetComponent <FEMALE_TITAN>().hasDie)
                         {
                             obj4.GetComponent <FEMALE_TITAN>().hitAnkleR(num9);
                         }
                     }
                     else if ((obj4.GetComponent <FEMALE_TITAN>() != null) && !obj4.GetComponent <FEMALE_TITAN>().hasDie)
                     {
                         obj4.GetComponent <FEMALE_TITAN>().hitAnkleL(num9);
                     }
                 }
                 else if (other.gameObject.name == "ankleR")
                 {
                     if (!PhotonNetwork.isMasterClient)
                     {
                         if (!obj4.GetComponent <FEMALE_TITAN>().hasDie)
                         {
                             object[] objArray8 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID, num9 };
                             obj4.GetComponent <FEMALE_TITAN>().photonView.RPC("hitAnkleRRPC", PhotonTargets.MasterClient, objArray8);
                         }
                     }
                     else if (!obj4.GetComponent <FEMALE_TITAN>().hasDie)
                     {
                         obj4.GetComponent <FEMALE_TITAN>().hitAnkleRRPC(base.transform.root.gameObject.GetPhotonView().viewID, num9);
                     }
                 }
                 else if (!PhotonNetwork.isMasterClient)
                 {
                     if (!obj4.GetComponent <FEMALE_TITAN>().hasDie)
                     {
                         object[] objArray9 = new object[] { base.transform.root.gameObject.GetPhotonView().viewID, num9 };
                         obj4.GetComponent <FEMALE_TITAN>().photonView.RPC("hitAnkleLRPC", PhotonTargets.MasterClient, objArray9);
                     }
                 }
                 else if (!obj4.GetComponent <FEMALE_TITAN>().hasDie)
                 {
                     obj4.GetComponent <FEMALE_TITAN>().hitAnkleLRPC(base.transform.root.gameObject.GetPhotonView().viewID, num9);
                 }
                 this.showCriticalHitFX();
             }
         }
     }
 }
Example #52
0
    public static GameObject GetGameObjectView(PhotonView m_view)
    {
        GameObject go = PhotonView.Find(m_view.viewID).gameObject;

        return(go);
    }
Example #53
0
 private void tieMeToOBJ(int id)
 {
     baseT.parent = PhotonView.Find(id).gameObject.transform;
 }
 void Start()
 {
     PV       = GetComponent <PhotonView>();
     miCamara = transform.GetChild(0).GetComponent <Camera>();
 }
Example #55
0
 public PhotonMessageInfo(PhotonPlayer player, int timestamp, PhotonView view)
 {
     this.sender     = player;
     this.timeInt    = timestamp;
     this.photonView = view;
 }
Example #56
0
    /*---------------------------- UPDATE ----------------------------*/

    // Update is called once per frame
    void Update()
    {
        PhotonView photonView = PhotonView.Get(this);

        //When our playerCreator is created we add ourself on the scoreboards
        playerSpawn playSpawn = GetComponent <playerSpawn>();


        //While we're not on the scoreboard we try to be added
        if (addedOnBoard == false)
        {
            //We make a string out of our gamertag and playerID
            string myTag = PlayerPrefs.GetString("Gamertag");
            int    myID  = photonView.owner.ID;

            //If we have all the components we send the RPC
            if (myTeam == "Blue" || myTeam == "Red")
            {
                string tagTeamID = myID.ToString() + ";" + myTag + ";" + myTeam;

                if (PhotonNetwork.isMasterClient)
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                }
                else
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                    photonView.RPC("updateMe", PhotonTargets.Others, myID);
                }

                /*if(photonView.isMine)
                 * {
                 *      addOnBoard(tagTeamID);
                 * }*/
                addedOnBoard = true;
            }
        }


        //Managing the kills

        //We update the last shot each frame
        foreach (Transform child in transform)
        {
            if (child.name != "scoreHUD" && child.name != "scoreBoardUI")
            {
                playerNetwork playSet = child.GetComponent <playerNetwork>();
                myLastShot = playSet.lastShot;
            }
        }

        //If we're killed we add the kill and update the score
        if (wasKilled)
        {
            int myID = photonView.owner.ID;
            if (myTeam == "Blue")
            {
                photonView.RPC("addRedKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addBlueDeath", PhotonTargets.All, myID);
            }
            else
            {
                photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addRedDeath", PhotonTargets.All, myID);
            }
            wasKilled = false;
        }

        /*--------------------------- SCOREBOARD ----------------------*/

        //We get the scoreboard object
        Transform scoreB = transform.Find("scoreBoardUI");

        //Drawing the score
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            drawTheScore = true;
        }
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            drawTheScore = false;
        }

        if (photonView.isMine)
        {
            if (drawTheScore)            //If the player press tab we activate the board
            {
                scoreB.gameObject.active = true;
            }
            else
            {
                scoreB.gameObject.active = false;
            }
        }
        else
        {
            scoreB.gameObject.active = false;
        }
    }
Example #57
0
 private void Awake()
 {
     m_photonView = GetComponent <PhotonView>();
     GameManager.AddActivePlayer(this);
 }
Example #58
0
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent <Rigidbody>();
     GetComponent <Rigidbody2D>().freezeRotation = true;
     photonView = GetComponent <PhotonView>();
 }
Example #59
0
    private void CreatePlayer(string charName)
    {
        string str = "";

        foreach (string s in data)
        {
            if (s.StartsWith(charName))
            {
                str = s;
                break;
            }
        }
        char[]     separator = { '\t' };
        string[]   arr       = str.Split(separator);
        GameObject obj;
        Vector3    coords = GameBoardRegion.regionCoords[int.Parse(arr[1])];

        obj      = (GameObject)PhotonNetwork.Instantiate(charName, coords, Quaternion.identity, 0);
        obj.name = charName;
        SceneManager.MoveGameObjectToScene(obj, SceneManager.GetSceneByName("GameScene"));
        PhotonView view = obj.GetPhotonView();

        view.RPC("DontDestroy", RpcTarget.AllBuffered);
        PhotonHashtable h = new PhotonHashtable();

        h.Add("Type", charName);
        h.Add("pos", int.Parse(arr[1]));
        h.Add("Hours", int.Parse(arr[2]));
        h.Add("DayIsEnded", false);
        h.Add("sp", int.Parse(arr[4]));
        h.Add("wp", int.Parse(arr[3]));
        h.Add("farmer", int.Parse(arr[5]));
        h.Add("gold", int.Parse(arr[6]));
        h.Add("deposit", 0);
        h.Add("wineskin", int.Parse(arr[8]));
        h.Add("shield", int.Parse(arr[9]));
        h.Add("falcon", int.Parse(arr[10]));
        h.Add("bow", int.Parse(arr[12]));
        h.Add("telescope", int.Parse(arr[11]));
        h.Add("helm", int.Parse(arr[13]));
        h.Add("brew", int.Parse(arr[14]));
        h.Add("herb", bool.Parse(arr[7]));
        h.Add("yellowStone", int.Parse(arr[15]));
        h.Add("blueStone", int.Parse(arr[16]));
        h.Add("greenStone", int.Parse(arr[17]));
        PhotonNetwork.SetPlayerCustomProperties(h);
        this.addPlayerToList(charName);
        Hero myHero = obj.GetComponent <Hero>();

        GameBoardRegion.setHero(myHero);

        float shift = 0;
        int   hours = int.Parse(arr[2]);

        if (hours > 7)    //account for uneven space between hour 7 and 8
        {
            shift += 0.55f;
        }
        shift += 1.75f * hours;
        GameObject o2 = (GameObject)PhotonNetwork.Instantiate(charName + "TimeTracker", new Vector3(-1.3f + shift, 12.55f, 15), Quaternion.identity, 0);

        o2.name = charName + "TimeTracker";
        SceneManager.MoveGameObjectToScene(o2, SceneManager.GetSceneByName("GameScene"));
        PhotonView v2 = o2.GetPhotonView();

        v2.RPC("DontDestroy", RpcTarget.AllBuffered);
        myHero.timeTrackToken = o2.GetComponent <SpriteRenderer>();
        int hrs = (int)PhotonNetwork.LocalPlayer.CustomProperties["Hours"];

        Debug.Log("newHours: " + hrs);
    }
Example #60
0
    void SetPlanetModel(int playerID, int index)
    {
        PhotonView player = PhotonView.Find(playerID);

        Instantiate(planetModels[index], player.transform);
    }