public SpaceshipControlls GetSpaceshipCmp() { if (_activeSpaceship == null) { if (GetActiveSpaceship() != null) _activeSpaceship = GetActiveSpaceship().GetComponent<SpaceshipControlls>(); } return _activeSpaceship; }
}//Start void LateUpdate() { if (!target && GameManager.Instance) { _spaceship = GameManager.Instance.GetSpaceshipCmp(); target = _spaceship.gameObject.transform; this.transform.position = LockVectorAxis(target.position); } if (!mainCamera) { mainCamera = Camera.main; } if (!target) //noone to follow { return; } if (!target) { return; } var targetPos = Follow(); transform.position = LockVectorAxis(targetPos); }//FixedUpdate
} // /* Check if a given spinner is Locked or Unlocked. if unlocked, a selection button * "activated" will be set to active and "locked" button will be set to disabled, * allowing player to select this spinner (or not).*/ public bool CheckSpinnerStatus(string spinnerName) { //WARNING: yes, hardcoded value here expected of a form "<spinner_name>_btn" string spinnerBtnName = spinnerName + "_btn_active"; UIElementID unlockedSpinnerBtn = UINavigation.Instance.GetElement(spinnerBtnName); if (unlockedSpinnerBtn == null) //not a spinner btn element you are looking for { return(false); } SpaceshipControlls spinnerCmp = this.spinners[spinnerName]; spinnerBtnName = spinnerName + "_btn_locked"; UIElementID lockedSpinnerBtn = UINavigation.Instance.GetElement(spinnerBtnName); if (lockedSpinnerBtn == null) // this should never happened, unless development branch. { return(false); } if (!spinnerCmp.isUnlocked) { unlockedSpinnerBtn.gameObject.SetActive(false); lockedSpinnerBtn.gameObject.SetActive(true); //lockedSpinnerBtn.textField.text = spinnerCmp.name + "\n" + spinnerCmp.pointsToUnlock; return(true); } unlockedSpinnerBtn.gameObject.SetActive(true); lockedSpinnerBtn.gameObject.SetActive(false); return(false); }//CheckSpinnerStatus
}//PullIn public void OnTriggerExit2D(Collider2D collision) { if (collision.tag != GameManager.Instance.GetActiveSpaceship().tag) { return; } _spaceshipControlls = GameManager.Instance.GetSpaceshipCmp(); _spaceshipControlls.SetIsCanMove(false); }//OnTriggerExit2D
}//onGameOver public void Reset() { isGameOver = false; isSlowmo = false; slowmoTime = 1; Time.timeScale = 1f; if(GetSpaceshipCmp() != null) GetSpaceshipCmp().Reset(); if(UINavigation.Instance) UINavigation.Instance.SetElementActive("GameOverMenu", false); _activeGameMode = null; _activeSpaceship = null; }//Reset
}//OnTriggerExit2D public void OnTriggerEnter2D(Collider2D collision) { if (GameManager.Instance != null && collision.tag != GameManager.Instance.GetActiveSpaceship().tag) { return; } if (_spaceshipControlls == null) { return; } _spaceshipControlls.RB.velocity = Vector2.zero; PullIn(_spaceshipControlls.RB); _spaceshipControlls.SetIsCanMove(true); _spaceshipControlls = null; } //OnTriggerEnter2D
// Use this for initialization public void Start () { isGameOver = false; isSlowmo = false; if (Instance != null) { DestroyImmediate(this.gameObject); return; } Instance = this; //Load values into GameState inside the LoadGame function. It will use GM's Instance. SaveLoad.Instance.LoadGame(); if (SpaceshipPrefab != null) _activeSpaceship = GetComponent<SpaceshipControlls>(); origTimeScale = Time.timeScale; DontDestroyOnLoad(this.gameObject); }//start
}//Update public void SetSpinner(GameObject spin) { SpaceshipPrefab = spin; _activeSpaceship = SpaceshipPrefab.GetComponent<SpaceshipControlls>(); }//SetSpinner
public override void Start() { base.Start(); _spaceship = GetComponent <SpaceshipControlls>(); }//Start