Inheritance: MonoBehaviour
Example #1
0
 void Start()
 {
     // Obtains the components from the PlayerMovement, CameraFollow and BlasterManager Script.
     playerMovementController = FindObjectOfType<PlayerMovement>();
     armMovementController = FindObjectOfType<BlasterManager>();
     cameraMovementController = FindObjectOfType<CameraFollow>();
 }
Example #2
0
	// Use this for initialization
	void Start () {
		camFollow = GameObject.Find("Main Camera").GetComponent<CameraFollow>();
		//spawn the player.
		Instantiate(player);
		//reference the CameraFollow script and set the target to the instantiated player.
		camFollow.target = player.transform;
	}
Example #3
0
	// Use this for initialization
	public void Start () {
		camera = Camera.main;
		maximumActivationDistance = 1.5f;
		myCamera = camera.GetComponent<CameraFollow> ();
		on = false;
		audioPP = this.gameObject.AddComponent<AudioSource>();
	}
Example #4
0
	void Start () {
		enabled = true;
        //find the camera object and obtain its script
        cameraObject = GameObject.Find("Main Camera");
		CameraScript = cameraObject.GetComponent<CameraFollow>();
		//initialize the object in control to be the head at first
		inControl = GameObject.Find("Player");
		ClosestLimb = FindClosestLimb();
		//collect all the objects with tags "leg" and "arm" in 
		//data structures
		Legs = GameObject.FindGameObjectsWithTag("leg");
		Arms = GameObject.FindGameObjectsWithTag("arm");
		//merge the two arrays into one

		player = GameObject.FindGameObjectWithTag("Player");
        sounds = player.GetComponent<Sound>();
        for (int i = 0; i < Legs.Length; i++) 
		{
			Limbs.Add(Legs[i]);
		}

		for (int i = 0; i < Arms.Length; i++) 
		{
			Limbs.Add(Arms[i]);
		}
	}
    void Start() {
        cameraFollow = GetComponent<CameraFollow>();
        cameraHeight = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>().orthographicSize;

        //REMOVE AT THE END OF THE DEVELOPMENT
        //UpdateTarget();
    }
    void Awake()
    {
        S = this;
        cameraZ = this.transform.position.z;

        maincam = GetComponent<Camera>();
    }
    void OnLevelWasLoaded(int level)
    {
        enemySpawnPoint = GameObject.Find("SpawnPoint2").GetComponent<Transform>();
        if (GameObject.Find(spawnPointName) != null)
        {
            spawnPoint = GameObject.Find(spawnPointName).GetComponent<Transform>();
        }
        else
        {
            spawnPoint = GameObject.Find("SpawnPoint").GetComponent<Transform>();
        }
        if (PhotonNetwork.isMasterClient)
        {
            //PhotonNetwork.InstantiateSceneObject("Orc", enemySpawnPoint.position, enemySpawnPoint.rotation, 0, null);
        }
        player = PhotonNetwork.Instantiate("Elf", spawnPoint.position, spawnPoint.rotation, 0);
        combatManager = player.GetComponent<PlayerCombatManager>();
        combatManager.enabled = true;
        playerRunes = player.GetComponent<Runes>();
        playerRunes.enabled = true;
        //player.GetComponent<Health>().enabled = true;
        cameraFollow = Camera.main.GetComponent<CameraFollow>();
        cameraFollow.enabled = true;
        playerHealth = player.GetComponent<Health>();
        //playerHealth.enabled = true;

    }
    private void Start() {
        instance = this;

        //us = transform;
        cam = GetComponent<tk2dCamera>();
        //minZoom = cam.ZoomFactor;
        targets = new Transform[maxTargets];
    }
Example #9
0
    void Awake( )
    {
        if (!tag.Equals("MainCamera"))
            Debug.LogError("CameraFollow必须放在主相机上");

        instance = this;
        m_tf = transform;
    }
 public override void OnStartLocalPlayer()
 {
     floorMask = LayerMask.GetMask ("Floor");
     anim = GetComponent<Animator> ();
     playerRigidbody = GetComponent<Rigidbody> ();
     playerCamera = Camera.main.GetComponent<CameraFollow> ();
     playerCamera.setPlayerTransform (transform);
 }
Example #11
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType<PlayerController> ();

        camera = FindObjectOfType<CameraFollow> ();

        healthManager = FindObjectOfType<HealthManager> ();
    }
	void Awake () {
		S = this;

        cam = GetComponent<Camera>();

		// Initially position the camera exactly over the poi - JB
		transform.position = poi.position + offset;
	}
Example #13
0
    void Start () 
    {
        cameraFollow = GameObject.FindObjectOfType<CameraFollow>();
        floor = GameObject.FindObjectOfType<FloorManager>();

        aspect = Mathf.Round(Camera.main.aspect * 100f) / 100f;
        if (aspect >= 1) aspect = 1;

        ShowStartMenu();
	}
Example #14
0
 // Use this for initialization
 void Start()
 {
     cam = GameObject.Find ("Main Camera");
     cPos = cam.GetComponent<CameraFollow> ();
     bar1.SetActive (false);
     bar2.SetActive (false);
     bar3.SetActive (false);
     wave = 0;
     delay = 0f;
 }
Example #15
0
    void Start()
    {
        mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraFollow>();

        for (int i = 0; i < characters.Count; i++) {
            characters[i].GetComponent<PlayerController>().enabled = false;
        }

        characters[0].GetComponent<PlayerController>().enabled = true;
        GameObject.Find(characters[0].GetComponent<Character>().color).transform.Translate(0, 0, 1);
        mainCamera.target = characters[0].GetComponent<PlayerController>();
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        hero = FindObjectOfType<HeroMovement>();

        if (hero.startPoint == pointName)
        {
            hero.transform.position = transform.position;

            cam = FindObjectOfType<CameraFollow>();
            cam.transform.position = new Vector3(transform.position.x, transform.position.y, cam.transform.position.z);

        }
    }
Example #17
0
    /// <summary>
    /// 设置像机区域
    /// </summary>
    public void SetCameraRange()
    {
        if (m_CameraFollow == null
                && Camera.main)
        {
            m_CameraFollow = Camera.main.GetComponent<CameraFollow>();
        }

        if (m_CameraFollow != null)
        {
            m_CameraFollow.SetRange(maxXAndY, minXAndY);
        }
    }
    void Start()
    {
        // Since they're taking turns, enforce this
        if (TolstoyDialog.Length - TeaganDialog.Length > 1)
            Debug.LogError("Tolstoy dialog piece needs to be at most one longer than the other.");

        // These are probably going to be uniqe so grab them this way
        cameraControl = Object.FindObjectOfType<CameraFollow>();
        dialog = Object.FindObjectOfType<DialogBox>();
        grayscale = Object.FindObjectOfType<Grayscale>();

        StartCoroutine(StartRoomCoroutine());
    }
    void Awake()
    {
        thirdPersonCamera = gameObject.GetComponent<ThirdPersonCameraScript>();
        singlePersonCamera = gameObject.GetComponent<CameraFollow>();

        if (!player)
        {
            Debug.LogWarning("Please assign your players in inspector. Setting B4 from script.");
            player = GameObject.FindGameObjectWithTag("B4");
        }

        singlePersonCamera.player = player.transform;
        changeCameraType(type);
    }
 void Start()
 {
     arrowHead.sizeDelta = new Vector2 (arrowHead.rect.width * ARROW_HEAD_SCALE_COEFFICIENT, arrowHead.rect.height * ARROW_HEAD_SCALE_COEFFICIENT);
     arrowTail.sizeDelta = new Vector2 (arrowTail.rect.width, arrowTail.rect.height * ARROW_TAIL_SCALE_COEFFICIENT);
     scoreKeepingScript = GameObject.Find ("World").GetComponent<ScoreKeeping> ();
     ballManagerScript = GetComponent<BallManager> ();
     cameraFollowScript = camera3D.GetComponent<CameraFollow> ();
     levelManage = GameObject.Find ("LevelManager");
     levelManagerScript = levelManage == null ? null : levelManage.GetComponent<LevelManager> ();
     arrowTailRenderer = arrowTail.GetComponent<CanvasRenderer> ();
     arrowTailRenderer.SetMaterial (arrowTailShader, null);
     distance = 0;
     arrowScalePercent = 0;
     overUI = false;
 }
Example #21
0
	/// <summary>
	/// Registers the camera.
	/// </summary>
	void RegisterCamera() 
	{

		camObj = GameObject.Find ("Player Camera");
		cam = camObj.GetComponent<Camera> ();
		cam.orthographicSize = 5f;
		camfollow = camObj.GetComponent<CameraFollow> ();
		camfollow.player = gameObject;

		camfollow.touchMovement = gameObject.GetComponent<TouchMovement> ();
		camfollow.aheadOfPlayer = transform.Find ("look ahead");

		camfollow.hasPlayer = true;

		camObj.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -1);
	}
Example #22
0
	void Start()
	{
		//switchControl = GameObject.FindGameObjectWithTag("Player").GetComponent<SwitchControl>();
		moveSpeed = 10f;
		playerAnim = GameObject.FindGameObjectWithTag("Player").GetComponent<Animator>() as Animator;
		camScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraFollow>();
		facingRight = true;
		myBoxcollider = gameObject.GetComponent<BoxCollider2D>() as BoxCollider2D;
		myAnimator = GetComponent<Animator>();
		myController = GetComponent<Controller2D>();
		print("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);
		limbController = GetComponent<LimbController>();
		sounds = GetComponent<Sound>();
		playSound = false;
		myTarget = camScript.target;
		notOnNose = true;
	}
    void OnTriggerExit(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            // Reset Camera...
            cFollow = Camera.main.GetComponent<CameraFollow>();

            // Reset to the values we had before starting.
            cFollow.followSpeed = OriginalTargetFollowSpeed;
            cFollow.target = OriginalTarget;
            cFollow.targetOffset = OriginalTargetOffset;

            if (OnlyTriggerOnce)
            {
                gameObject.GetComponent<Collider>().enabled = false;
            }
        }
    }
 // Awake is used to initialize any variables or game state before the game starts
 void Awake()
 {
     _countCheck = PlayerPrefs.GetInt("CountCheck",0);
     _cam = GetComponent<CameraFollow>();
     if(PlayerPrefsX.GetVector3("CheckSpawn")==Vector3.zero){
         if(GameObject.FindGameObjectWithTag("Respawn")){
             GameObject _respawn = GameObject.FindGameObjectWithTag("Respawn");
             _checkpoint = new Vector3(_respawn.transform.position.x,_respawn.transform.position.y-_respawn.GetComponent<BoxCollider2D>().size.y/2,_respawn.transform.position.z);
             _distance = Mathf.Abs(_cam.deadStart.transform.position.x - _checkpoint.x);
         }
     }else{
         _checkpoint = PlayerPrefsX.GetVector3("CheckSpawn");
         if(GameObject.FindGameObjectWithTag("Respawn")){
             GameObject _respawn = GameObject.FindGameObjectWithTag("Respawn");
             _distance = Mathf.Abs(_cam.deadStart.transform.position.x - _respawn.transform.position.x);
         }
     }
     SpawnPlayer (_checkpoint);
 }
Example #25
0
    void Awake()
    {
        m_MainCamera = transform;
        _instance = this;

        m_Follower = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();

        //// 设置跟随目标
        //GameObject followPlayer = GameObject.FindGameObjectWithTag("Player");
        //if(followPlayer != null)
        //{
        //    Actor actor = followPlayer.GetComponent<Actor>();
        //    if(actor != null)
        //    {
        //        actor.onOutofView = this.OnFollowerOutOfView;
        //    }
        //}
        CalculateViewPointSize();
    }
 //We should trigger if the player enters our trigger
 void OnTriggerEnter(Collider other)
 {
     //If what entered our trigger has the TAG Player...
     if (other.gameObject.CompareTag("Player"))
     {
         //Let's ask the Camera to give us their Camera Follow component to mess with!
         cFollow = Camera.main.GetComponent<CameraFollow>();
         //Let's set the original values that are there right now so we can get back to it later.
         OriginalTarget = cFollow.target;
         OriginalTargetOffset = cFollow.targetOffset;
         OriginalTargetFollowSpeed = cFollow.followSpeed;
         //Also let's set our PlayerMove Script to be the Player that just touched us. So we can disable him.
         pMove = other.gameObject.GetComponent<PlayerMove>();
         //And let's turn this trigger off because... I don't want this being triggered while it's playing the cinematic
         //If that happens I'll be in trouble since I won't have the original values anymore
         gameObject.GetComponent<Collider>().enabled = false;
         //And finally... Let's start the Cinematic!
         StartCoroutine(StartCinematic());
     }
 }
Example #27
0
    void Awake()
    {
        guiManager = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUIManager>();
        guiHelper = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUIHelper>();
        camController = GameObject.Find("Main Camera").GetComponent<CameraFollow>();
        pauseItems = GameObject.FindGameObjectsWithTag("PauseItem");
        endgameItems = GameObject.FindGameObjectsWithTag("ResultItem");

        if (!goal)
            goal = GameObject.FindGameObjectWithTag("Goal");

        foreach (GameObject item in pauseItems)
        {
            item.SetActive(false);
        }

        foreach (GameObject item in endgameItems)
        {
            item.SetActive(false);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            cFollow = Camera.main.GetComponent<CameraFollow>();

            // Set the original values that are there right now so we can get back to it later.
            OriginalTarget = cFollow.target;
            OriginalTargetOffset = cFollow.targetOffset;
            OriginalTargetFollowSpeed = cFollow.followSpeed;

            cFollow.followSpeed = TargetFollowSpeed;
            if (TargetIsPlayer)
            {
                cFollow.target = other.gameObject.transform;
            }
            else
            {
                cFollow.target = Target1;
            }
            cFollow.targetOffset = TargetOffset;
        }
    }
    // Use this for initialization
    void Start()
    {
        rnd = new System.Random(System.Guid.NewGuid().GetHashCode());
        Camera camera = Camera.main;
        cameraFollow = camera.GetComponent<CameraFollow>();
        mainprocess = FindObjectOfType<Main_Process>();

        InstanceID = CreateStart.AreaID[CreateStart.roomCount-1];
        //Debug.Log("InstanceID: " + InstanceID + ", " + (CreateStart.roomCount-1));

        room = FindObjectOfType<CreateStart>().GetComponent<CreateStart>();

        if (CreateStart.roomCount != 1) //never create a mob in the first room
        {
            room.MakeMob(CreateStart.roomCount);
            room.MakeObjects(CreateStart.roomCount);
        }

        if (CreateStart.squadSize == 0)
            E_Dead = true;

        end = GameObject.Find("Main Process").GetComponent<Main_Process>();
    }
Example #30
0
    void Start()
    {
        // Initializers
        aUtil         = FindObjectOfType <AspectUtility>();
        camFollow     = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>();
        chars         = GetComponent <Characters>();
        dArrow        = GameObject.Find("Dialogue_Arrow").GetComponent <ImageStrobe>();
        dBox          = GameObject.Find("Dialogue_Box");
        dMan          = FindObjectOfType <DialogueManager>();
        dPic          = GameObject.Find("Dialogue_Picture").GetComponent <Image>();
        dText         = GameObject.Find("Dialogue_Text").GetComponent <Text>();
        HUD           = GameObject.Find("HUD");
        mainCamera    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
        mMan          = FindObjectOfType <MusicManager>();
        moveOptsArw   = FindObjectOfType <MoveOptionsMenuArrow>();
        muellerCards  = GameObject.Find("Mueller Cards");
        oBox          = GameObject.Find("Options_Box");
        oMan          = FindObjectOfType <OptionsManager>();
        pause         = FindObjectOfType <PauseGame>();
        pauseBtn      = GameObject.Find("Pause_Button");
        pauseScreen   = GameObject.FindGameObjectWithTag("Pause");
        playerCard    = GameObject.Find("Player_Character_Card");
        save          = FindObjectOfType <SaveGame>();
        sFaderAnim    = GameObject.Find("Screen_Fader");
        sFaderAnimDia = GameObject.Find("Screen_Fader_Dialogue");
        SFXMan        = FindObjectOfType <SFXManager>();
        spLogic       = FindObjectOfType <SinglePlayerLogic>();
        thePlayer     = GameObject.FindGameObjectWithTag("Player");
        touches       = FindObjectOfType <TouchControls>();
        trumpCards    = GameObject.Find("Trump Cards");
        uMan          = FindObjectOfType <UIManager>();

        charTiles = new CharacterTile[24];

        guessThreshold = 1.25f;
        musicTimer1    = 5.39f;
        musicTimer2    = 1.05f;
        strobeTimer    = 1.0f;

        // Trump Dialogue
        //dialogueLines = new string[] {
        //        "There was no collusion. Everybody knows there was no collusion.",
        //        "The Fake News, the Disgusting Democrats, and the Deep State would say different."
        //    };

        // Initial prompt to pick a mode
        dMan.bDialogueActive = false;
        mMan.bMusicCanPlay   = false;

        GWC_PromptRestrictions();

        // First Time w/ App, set to "Factory Settings"
        if (PlayerPrefs.GetInt("GivenDirectionsForGWC") == 0)
        {
            save.DeleteAllPrefs();

            dialogueLines = new string[] {
                "I want YOU.. to         Guess Who Colluded.",
                "Like classic Guess Who, you'll be flipping tiles and guessing people.",
                "Tap or click options when they appear below this text box.",
                "Tap or click tiles to keep track of who your opponent is.",
                "If you have trouble, click the menu icon in the top right.",
                "It'll show you your character card, let you change settings, etc.",
                "GLHF!"
            };

            // Avoid "Factory Settings"
            PlayerPrefs.SetInt("GivenDirectionsForGWC", 1);
        }
        else
        {
            dialogueLines = new string[] {
                "I want YOU.. to         Guess Who Colluded."
            };
        }

        dMan.dialogueLines        = dialogueLines;
        dMan.currentLine          = 0;
        dText.text                = dialogueLines[dMan.currentLine];
        dPic.sprite               = portPic[48];
        dBox.transform.localScale = Vector3.one;
        sFaderAnimDia.GetComponent <Animator>().enabled = true;

        thePlayer.GetComponent <PlayerMovement>().bStopPlayerMovement = true;
    }
Example #31
0
 void Start()
 {
     menuEvent = mainCamera.GetComponent <CameraFollow>();
     //给静态变量赋值
     introduceOnUI = PubintroduceOnUI;
 }
Example #32
0
 void Start()
 {
     instance = this;
 }
 void Start()
 {
     target    = GameObject.Find("black_knight").transform;
     camFollow = GetComponent <CameraFollow>();
 }
Example #34
0
 void Start()
 {
     GetComponent <Renderer>().enabled = false;
     camFollow = GameObject.FindWithTag("MainCamera").GetComponent <CameraFollow>();
 }
Example #35
0
 private void Start()
 {
     game         = GameObject.Find("Game").GetComponent <Game>();
     cameraFollow = GameObject.Find("Main Camera").GetComponent <CameraFollow>();
 }
 private void Start()
 {
     Cursor.SetCursor(cursor, Vector2.zero, CursorMode.ForceSoftware);
     lr = hud.GetComponent <LineRenderer>();
     mainCameraFollow = Camera.main.GetComponent <CameraFollow>();
 }
Example #37
0
 void Awake()
 {
     player       = GetComponent <Player> ();
     cameraFollow = Camera.main.GetComponent <CameraFollow> ();
 }
    void Start()
    {
        cameraFollow = this;

        //transform.Rotate (5, 0, 0);
    }
Example #39
0
 // Use this for initialization
 void Start()
 {
     LoadLevel(levelName);
     GameControl.control.SpawnPlayers();
     CameraFollow.RegisterPlayers();
 }
Example #40
0
 public void TargetSetCameraTarget(NetworkConnection conn, GameObject target)
 {
     mainCameraFollow = Camera.main.GetComponent <CameraFollow>();
     mainCameraFollow.SetTarget(target.GetComponent <Entity>());
 }
Example #41
0
 private void OnDestroy()
 {
     Instance = null;
 }
Example #42
0
 public void setCamera(CameraFollow cam)
 {
     this.cam = cam;
 }
Example #43
0
 // Start is called before the first frame update
 void Start()
 {
     cameraFollow = FindObjectOfType <CameraFollow>();
 }
Example #44
0
 void Awake()
 {
     instance = this;
     Application.targetFrameRate = 60;
     cameraStartingPosition      = this.transform.position;
 }
Example #45
0
 private void Awake() => cf = GetComponent <CameraFollow>();
Example #46
0
 private void Awake()
 {
     s_mainCamera = this;
     m_transform  = GetComponent <Transform>();
 }
Example #47
0
    public Text placeText;   //vart texten är i UI


    void Start()
    {
        cam = Camera.main.GetComponent <CameraFollow>(); //hämtar camerafollow skriptet.
    }
Example #48
0
 void Start()
 {
     actionController = GetComponent <ActionController>();
     cameraController = GetComponent <CameraController>();
     cameraFollow     = GetComponent <CameraFollow>();
 }
Example #49
0
 void Awake()
 {
     S = this;         //CameraFollow singleton
 }
Example #50
0
 void Start()
 {
     Instantiate(followTarget);
     CameraFollow.AddTarget(followTarget);
 }
Example #51
0
 void Awake()
 {
     instance   = this;
     thisCamera = GetComponent <Camera> ();
 }
Example #52
0
    IEnumerator MainCycle()
    {
        while (true)
        {
            if (msgQueue.Count < 1)
            {
                // haven't any packets
                yield return(new WaitForSeconds(0.01f));
            }
            else
            {
                PacketMSG receivedPacket = (PacketMSG)msgQueue.Dequeue();
                int       packetId       = receivedPacket.Cmd;
                Cmd       cmd            = (Cmd)packetId;
                switch (cmd)
                {
                case Cmd.CmdPing:
                    break;

                case Cmd.CmdLogin:
                    break;

                case Cmd.CmdLoginSuccess:
                    break;

                case Cmd.CmdLoginFailed:
                    break;

                case Cmd.CmdSetFamilyRequest:
                    managerUI.SetStateSetFamily();
                    break;

                case Cmd.CmdSetFamily:
                    break;

                case Cmd.CmdSetFamilySuccess:
                    break;

                case Cmd.CmdSetFamilyFailed:
                    break;

                case Cmd.CmdPreviewAvatar:
                    break;

                case Cmd.CmdPreviewAvatars:

                    // очень грязный хак
                    chooseCharacterWindow.ClearSubs();
                    // </>

                    PacketPreviewAvatars packetPreviewAvatars = PacketPreviewAvatars.Parser.ParseFrom(receivedPacket.Data);
                    foreach (PacketPreviewAvatar packetPreviewAvatar in packetPreviewAvatars.Avatars)
                    {
                        chooseCharacterWindow.AddCharacter(packetPreviewAvatar.AvatarId, packetPreviewAvatar.Name, packetPreviewAvatar.Level);
                    }
                    int startArrayId = (packetPreviewAvatars.Avatars.Count == 0) ? 1 : packetPreviewAvatars.Avatars.Count;
                    for (int avatarArrayId = startArrayId; avatarArrayId <= packetPreviewAvatars.MaxAvatars; avatarArrayId++)
                    {
                        if (avatarArrayId <= packetPreviewAvatars.AvailableAvatars)
                        {
                            chooseCharacterWindow.AddAvailable();
                        }
                        else
                        {
                            chooseCharacterWindow.AddDisable();
                        }
                    }

                    managerUI.SetStateChooseAvatar();
                    break;

                case Cmd.CmdSetNewAvatar:
                    managerUI.SetStateSetNewAvatar();
                    break;

                case Cmd.CmdSetNewAvatarSuccess:
                    break;

                case Cmd.CmdSetNewAvatarFailed:
                    break;

                case Cmd.CmdJoinToChannel:
                    break;

                case Cmd.CmdAvatar:
                    break;

                case Cmd.CmdAvatars:
                    // action
                    PacketAvatars packetAvatars = PacketAvatars.Parser.ParseFrom(receivedPacket.Data);

                    foreach (PacketAvatar packetAvatar in packetAvatars.Avatars)
                    {
                        handlePacketAvatar(packetAvatar, respawn: false);
                    }
                    break;

                case Cmd.CmdJoinedAvatar:
                    if (players.Count == 0)
                    {
                        managerUI.SetStateGameplay();
                    }

                    PacketJoinedAvatar packetJoinedAvatar = PacketJoinedAvatar.Parser.ParseFrom(receivedPacket.Data);
                    PacketAvatar       packetAvatarJA     = packetJoinedAvatar.Avatar;
                    PacketTransform    packetTransformJA  = packetAvatarJA.Transform;
                    Vector3            receivedPositionJA = new Vector3(packetAvatarJA.Transform.Position.X, packetAvatarJA.Transform.Position.Y, packetAvatarJA.Transform.Position.Z);
                    Vector3            receivedRotationJA = new Vector3(0f, packetAvatarJA.Transform.Rotation.Yaw, 0f);

                    GameObject newPlayer;

                    if (packetAvatarJA.AvatarId == this.avatarId)                       // if it's our player, we spawn prefab with input controller
                    {
                        newPlayer = (GameObject)Instantiate(playerPrefab, receivedPositionJA, Quaternion.identity);
                        CameraFollow cameraScript = gameplayCamera.AddComponent <CameraFollow> ();
                        cameraScript.OnAwake(newPlayer.transform);
                    }
                    else                         // otherwise prebaf enemy without input controller
                    {
                        newPlayer = (GameObject)Instantiate(enemyPrefab, receivedPositionJA, Quaternion.identity);
                    }

                    newPlayer.name = packetAvatarJA.Name;
                    newPlayer.transform.position    = receivedPositionJA;
                    newPlayer.transform.eulerAngles = receivedRotationJA;

                    // add health Avatar script to avatar
                    Avatar avatarScript = newPlayer.GetComponent <Avatar> ();
                    if (packetAvatarJA.AvatarId == this.avatarId)                       // if it's our player
                    {
                        avatarScript.isMine = true;
                    }
                    avatarScript.AvatarId   = packetAvatarJA.AvatarId;
                    avatarScript.AvatarName = packetAvatarJA.Name;
                    avatarScript.FamilyId   = packetAvatarJA.FamilyId;
                    avatarScript.FamilyName = packetAvatarJA.FamilyName;
                    avatarScript.Level      = packetAvatarJA.Level;
                    avatarScript.AnimState  = packetAvatarJA.AnimState;

                    ///////////////////////////////////////////////////////////////////////// HEALTH
                    // add Health script to avatar
                    Health health = newPlayer.GetComponent <Health> ();

                    ///////////////////////////////////////////////////////////////////////// MANNA
                    // add manna script to avatar
                    Manna manna = newPlayer.GetComponent <Manna> ();

                    // gameplay UI
                    HealthView globalHealthView = null;
                    MannaView  globalMannaView  = null;

                    if (packetAvatarJA.AvatarId == this.avatarId)                       // if it's our player, we spawn prefab with input controller
                    // find avatar bars
                    {
                        GameObject avatarBars = GameObject.FindGameObjectWithTag("AvatarBars");

                        // add health UI
                        GameObject globalHealthUI = (GameObject)Instantiate(healthUIPrefab, Vector3.zero, Quaternion.identity);
                        globalHealthUI.transform.SetParent(avatarBars.transform, false);
                        globalHealthView = globalHealthUI.GetComponent <HealthView> ();
                        health.AddGlobalHealthView(globalHealthView);

                        // add manna UI
                        GameObject globalMannaUI = (GameObject)Instantiate(mannaUIPrefab, Vector3.zero, Quaternion.identity);
                        globalMannaUI.transform.SetParent(avatarBars.transform, false);
                        globalMannaView = globalMannaUI.GetComponent <MannaView> ();
                        manna.AddGlobalMannaView(globalMannaView);
                    }

                    avatarScript.Health = health;
                    health.Maximum      = packetAvatarJA.Health.Maximum;
                    health.Current      = packetAvatarJA.Health.Current;

                    avatarScript.Manna = manna;
                    manna.Maximum      = packetAvatarJA.Manna.Maximum;
                    manna.Current      = packetAvatarJA.Manna.Current;
                    CapsuleCollider capsuleCollider = newPlayer.GetComponent <CapsuleCollider> ();
                    capsuleCollider.enabled = true;
                    players.Add(packetAvatarJA.AvatarId, newPlayer);

                    break;

                case Cmd.CmdShootToAvatar:
                    break;

                case Cmd.CmdShootSuccess:
                    PacketShootSuccess packetShootSuccess = PacketShootSuccess.Parser.ParseFrom(receivedPacket.Data);
                    PacketAvatar       senderAvatarOne    = packetShootSuccess.SenderAvatar;
                    PacketPosition     packetPosition     = packetShootSuccess.ShootEndPosition;
                    Vector3            shootEndPosition   = new Vector3(packetPosition.X, packetPosition.Y, packetPosition.Z);

                    ShootSync shootSyncOne = players [senderAvatarOne.AvatarId].GetComponentInChildren <ShootSync> ();
                    shootSyncOne.ShootOn(shootEndPosition);
                    break;

                case Cmd.CmdShootToAvatarSuccess:
                    PacketShootToAvatarSuccess packetShootToAvatarSuccess = PacketShootToAvatarSuccess.Parser.ParseFrom(receivedPacket.Data);
                    int senderShootAvatarId   = packetShootToAvatarSuccess.SenderShootAvatarId;
                    int receiverShootAvatarId = packetShootToAvatarSuccess.ReceiverShootAvatarId;

                    ShootSync shootSyncTwo = players [senderShootAvatarId].GetComponentInChildren <ShootSync> ();
                    shootSyncTwo.ShootOn(players [receiverShootAvatarId].transform.position);
                    break;

                case Cmd.CmdShootFailed:
                    Debug.Log("Shoot failed");
                    break;

                case Cmd.CmdKilledBy:
                    Debug.Log("CmdKilledBy");
                    PacketKilledBy packetKilledBy = PacketKilledBy.Parser.ParseFrom(receivedPacket.Data);
                    int            killerAvatarId = packetKilledBy.KillerAvatarId;
                    int            victimAvatarId = packetKilledBy.VictimAvatarId;

                    if (victimAvatarId == this.avatarId)
                    {
                        gameplayWindow.KilledByCoroutineOn(string.Format("You were killed by {0}", players [killerAvatarId].name));
                    }
                    else
                    {
                        gameplayWindow.KilledByCoroutineOn(string.Format("{0} is killed by {1}", players [victimAvatarId].name, players [killerAvatarId].name));
                    }

                    break;

                case Cmd.CmdRespawn:
                    PacketRespawn packetRespawn = PacketRespawn.Parser.ParseFrom(receivedPacket.Data);
                    handlePacketAvatar(packetRespawn.Avatar, respawn: true);
                    break;

                case Cmd.CmdAvatarLeft:
                    PacketAvatarLeft packetAvatarLeft = PacketAvatarLeft.Parser.ParseFrom(receivedPacket.Data);
                    GameObject       link             = players [packetAvatarLeft.AvatarId];
                    players.Remove(packetAvatarLeft.AvatarId);
                    DestroyImmediate(link);
                    break;

                case Cmd.CmdBanned:
                    break;

                case Cmd.CmdDisconnect:
                    break;

                default:
                    break;
                }         // end switch
            }             // end else
            yield return(new WaitForSeconds(0.01f));
        }
    }
Example #53
0
    void Start()
    {
        god = GameObject.FindGameObjectWithTag ("God").GetComponent<UnifiedSuperClass> ();

        characters = god.getCurrentCharacters();
        camera = GetComponent<CameraFollow>();
        //		Debug.Log("Characters size " + characters.Count);
        current = characters[0].CharacterGameObject;
        lastSafeLocation = current.transform.position;
    }
Example #54
0
 void Awake()
 {
     PV  = GetComponent <PhotonView>();
     cam = GameObject.FindObjectOfType <CameraFollow>();
 }