public void SetAffector(PlayerController player) { if (player) { worldWrappingControl = player.GetComponent <WorldWrappingController>(); } else { worldWrappingControl = null; } }
void _DeserializeToInfo(string json) { var info = JsonConvert.DeserializeObject <FocusSaveInfo>(json); worldWrappingControl = GetComponent <WorldWrappingController>(); if (worldWrappingControl) { worldWrappingControl.IsCanFocus = info.unlocked_Focus; worldWrappingControl.IsCanMoveMode = info.unlocked_MoveMode; worldWrappingControl.IsCanEditMode = info.unlocked_EditMode; } }
void _SerializeToJson() { var info = new FocusSaveInfo(); worldWrappingControl = GetComponent <WorldWrappingController>(); if (worldWrappingControl) { info.unlocked_Focus = worldWrappingControl.IsCanFocus; info.unlocked_MoveMode = worldWrappingControl.IsCanMoveMode; info.unlocked_EditMode = worldWrappingControl.IsCanEditMode; } json = JsonConvert.SerializeObject(info, Formatting.None); }
void _Initialize() { anim = GetComponent <Animator>(); rigid = GetComponent <Rigidbody2D>(); audioSource = GetComponent <AudioSource>(); ground = transform.Find("ground"); feet = transform.Find("footstep"); footStepAudioPlayer = transform.Find("footstep").gameObject.GetComponent <FootStepAudioPlayer>(); cameraFollow = Camera.main.GetComponent <CameraFolllow>(); newScale = transform.localScale; worldWrappingControl = GetComponent <WorldWrappingController>(); render = GetComponent <SpriteRenderer>(); isControlable = true; platformAttacher = GetComponent <PlatformAttacher>(); }
void _InputHandler() { if (isUsing) { if (Input.GetButtonDown("Interact")) { if (playerControl) { playerControl.IsUsingBox = false; playerControl.AvatarDirFromBox = Vector2.zero; } isUsing = false; isInitUsing = false; } if (playerControl) { var axisX = Input.GetAxisRaw("Horizontal"); //Hacks if (worldWrappingControl) { if (worldWrappingControl.IsInEditMode || worldWrappingControl.IsInMoveMode) { axisX = 0.0f; } } else { axisX = 0.0f; } if (axisX > 0.0f) { inputVector.x = 1.0f; } else if (axisX < 0.0f) { inputVector.x = -1.0f; } else { inputVector.x = 0.0f; } } } else { if (hit) { if (!isInteractable) { return; } if (Input.GetButtonDown("Interact")) { isInitUsing = true; isUsing = true; playerControl = hit.GetComponent <PlayerController>(); if (playerControl) { worldWrappingControl = playerControl.GetComponent <WorldWrappingController>(); } if (playerControl && !playerControl.IsUsingBox) { playerControl.IsUsingBox = true; if (playerControl.gameObject.transform.position.x > transform.position.x) { playerControl.AvatarDirFromBox = Vector2.right; } else if (playerControl.gameObject.transform.position.x < transform.position.x) { playerControl.AvatarDirFromBox = Vector2.left; } } if (isEffectByFocus && focusEffector) { focusEffector.SetAffector(playerControl); focusEffector.UseEffector(true); } } } else { if (playerControl) { if (isInitUsing) { if (!isUsing) { playerControl.IsUsingBox = false; playerControl.AvatarDirFromBox = Vector2.zero; } isInitUsing = false; } if (isEffectByFocus) { if (worldWrappingControl) { if (!worldWrappingControl.IsUseFocus) { playerControl = null; worldWrappingControl = null; focusEffector.SetAffector(null); focusEffector.UseEffector(false); } } } else { playerControl = null; worldWrappingControl = null; } } } } }