示例#1
0
 public void LoadConfig(CameraFollowConfig state, bool loadPosition = true)
 {
     if (loadPosition)
         transform.position = state.position;
     minXAndY = state.minXAndY;
     maxXAndY = state.maxXAndY;
     isLocked = state.isLocked;
     lockedPosition = state.lockedPosition;
     lockedOrthoSize = state.orthoSize;
 }
示例#2
0
    private Transform player; // Reference to the player's transform.

    #endregion Fields

    #region Methods

    public CameraFollowConfig GetConfig()
    {
        CameraFollowConfig retVal = new CameraFollowConfig();
        retVal.position = transform.position;
        retVal.minXAndY = minXAndY;
        retVal.maxXAndY = maxXAndY;
        retVal.isLocked = isLocked;
        retVal.lockedPosition = lockedPosition;
        retVal.orthoSize = lockedOrthoSize;
        return retVal;
    }
示例#3
0
 public void StepConvo()
 {
     bool flag = false;
     if (playerObj.GetComponent<PlayerBallControl>() != null) {
         PlayerBallControl bScript = playerObj.GetComponent<PlayerBallControl>();
         flag = bScript.inConversation;
         if (!flag) {
             bScript.inConversation = true;
             bScript.npcTalker = transform;
             bScript.playerLock = true;
         }
     } else if (playerObj.GetComponent<PlayerBodyControl>() != null) {
         PlayerBodyControl bScript = playerObj.GetComponent<PlayerBodyControl>();
         flag = bScript.inConversation;
         if (!flag) {
             bScript.inConversation = true;
             bScript.npcTalker = transform;
             bScript.playerLock = true;
         }
     }
     if (!flag)
     {
         this.inConversation = true;
         if (talkSrc != null)
             talkSrc.Play();
         if (talkBubble != null)
             talkBubble.gameObject.SetActive(false);
         if (playerObj.GetComponent<PowerupManager>() != null &&
             playerObj.GetComponent<PowerupManager>().currentPowerup == PowerupType.Balloon) {
             playerObj.GetComponent<PowerupManager>().EndPowerup();
         }
         if (cam.GetComponent<Camera>().orthographicSize > cameraOrthoThreshold) {
             lastConfig = cam.GetComponent<CameraFollow>().GetConfig();
             CameraFollowConfig camConfig = new CameraFollowConfig();
             camConfig.position = transform.position;
             camConfig.lockedPosition = transform.position;
             camConfig.isLocked = true;
             camConfig.orthoSize = cameraOrthoThreshold;
             cam.GetComponent<CameraFollow>().LoadConfig(camConfig, false);
             changedCamConfig = true;
         }
         else
             changedCamConfig = false;
         dSystem.GetComponent<DialogueSystem>().npcBgColor = npcBoxColor;
     }
     if (inConversation)
     {
         if (dSystem.GetComponent<DialogueSystem>().IsAnimating())
             dSystem.GetComponent<DialogueSystem>().StepAnimation();
         else
         {
             List<string> lines = dialogue.Step(dSystem.GetComponent<DialogueSystem>().GetCursor());
             if(lines.Count > 0)
             {
                 string name = npcName;
                 if (lines[0].IndexOf(':') != -1)
                 {
                     name = lines[0].Substring(0, lines[0].IndexOf(':'));	//the colon is reserved for specifying speaker manually
                     lines[0] = lines[0].Substring(lines[0].IndexOf(':')+1);
                 }
                 dSystem.GetComponent<DialogueSystem>().PushNPCText(lines[0], transform.position, name);
                 dSystem.GetComponent<DialogueSystem>().PushPlayerText(lines.GetRange(1, lines.Count - 1), playerObj.transform.position);
                 playerObj.rigidbody2D.velocity = Vector2.zero;
                 playerObj.rigidbody2D.angularVelocity = 0f;
             }
             else
             {
                 dSystem.GetComponent<DialogueSystem>().EndConversation();
                 this.inConversation = false;
                 if (playerObj.GetComponent<PlayerBallControl>() != null) {
                     PlayerBallControl bScript = playerObj.GetComponent<PlayerBallControl>();
                     bScript.inConversation = false;
                     bScript.playerLock = false;
                 } else if (playerObj.GetComponent<PlayerBodyControl>() != null) {
                     PlayerBodyControl bScript = playerObj.GetComponent<PlayerBodyControl>();
                     bScript.inConversation = false;
                     bScript.playerLock = false;
                 }
                 endedTalkFrame = Time.frameCount;
                 if (talkBubble != null)
                     talkBubble.gameObject.SetActive(true);
                 if (changedCamConfig)
                     cam.GetComponent<CameraFollow>().LoadConfig(lastConfig, false);
             }
         }
     }
 }
示例#4
0
 void Start()
 {
     if (!debugNoLoad)
         LoadCurrentSave ();
     if (debugInitCamera && !loadedLevel)
     {
         GameObject cam = GameObject.FindGameObjectWithTag("MainCamera");
         CameraFollowConfig cfc = new CameraFollowConfig();
         cfc.minXAndY = new Vector2(-1000f, -1000f);
         cfc.maxXAndY = new Vector2(1000f, 1000f);
         cfc.isLocked = false;
         cfc.orthoSize = 7f;
         cfc.position = new Vector3(this.transform.position.x, this.transform.position.y, -10f);
         cam.GetComponent<CameraFollow>().LoadConfig(cfc);
     }
     if (debugInitRespawn)
     {
         Death.respawn = new Vector2(transform.position.x, transform.position.y);
         Death.camConfig = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraFollow>().GetConfig();
     }
 }
示例#5
0
    //for the convenience camera locked state
    private static void InitCheck(int id, string name, float xloc, float yloc, 
	                              float xcam, float ycam, float orthosize)
    {
        CheckpointData data = new CheckpointData();
        data.id = id;
        data.name = name;
        data.location = new Vector3 (xloc, yloc, 0f);

        CameraFollowConfig camConfig = new CameraFollowConfig();
        camConfig.isLocked = true;
        camConfig.position = new Vector3(xcam, ycam, CameraFollow.camZCoordinate);
        camConfig.lockedPosition = new Vector3(xcam, ycam, CameraFollow.camZCoordinate);
        camConfig.orthoSize = orthosize;

        data.camConfig = camConfig;
        checkpointMapping[id] = data;
    }