public void LoadCellData() { activeGame.RegenerateEnemies(); CellController mainCell = VariableContainer.variableContainer ? VariableContainer.variableContainer.mainCell : FindObjectOfType <CellController>(); activeGame.LoadCellData(mainCell.vars); }
/// <summary> /// Based on clone type, manages powerup handing mechanic from clone to original /// </summary> private void ReturnPowerups(CellController cloneToKill) { switch (cloneToKill.vars.type) { case CellType.M_FIGHTER: mainCell.vars.hasGuitar = cloneToKill.vars.hasGuitar; break; case CellType.R_FIGHTER: mainCell.vars.hasGun = cloneToKill.vars.hasGun; break; case CellType.JUMPER: mainCell.vars.hasDoubleJump = cloneToKill.vars.hasDoubleJump; mainCell.vars.hasTripleJump = cloneToKill.vars.hasTripleJump; break; case CellType.SLINGER: mainCell.vars.hasWallJump = cloneToKill.vars.hasWallJump; mainCell.vars.hasSlingJump = cloneToKill.vars.hasSlingJump; break; case CellType.GROUND: mainCell.vars.hasGroundPound = cloneToKill.vars.hasGroundPound; mainCell.vars.hasChargeDash = cloneToKill.vars.hasChargeDash; break; } }
public override void Shoot(CellController cell, Vector2 direction, float shotLength, float chargeRate) { travelDistance = shotLength; this.cell = cell; if (cell.vars.faceLeft) { speed *= -1; } }
public void TriggerInteraction(Transform CellPosition) { CellController mainCell = VariableContainer.variableContainer.mainCell; mainCell.vars.saveCheckpoint = transform.position; mainCell.vars.savedRoom = SceneManager.GetActiveScene().name; VariableContainer.variableContainer.currentActive.FullRecovery(); SaveManager.saveManager.SaveGame(); }
/// <summary> /// Destroys a clone that is currently in control /// </summary> private void DestroyActiveClone() { index = 0; CellController cloneToKill = currentActive; CellController newCell = clones[index]; SetActiveAndCam(newCell); DestroyShared(cloneToKill); }
private void OnTriggerEnter2D(Collider2D collision) { CellController cell = null; if ((cell = collision.gameObject.GetComponent <CellController>()) != null) { cell.SetCheckpoint(transform.position); } }
/// <summary> /// Shared code to set a new player/clone as the new active clone/player, manages camera, states and references. /// </summary> /// <param name="cellToActive">The player/clone to set as the new active</param> private void SetActiveAndCam(CellController cellToActive) { CameraManager.cameraManager.AddNewTarget(cellToActive.transform); cellToActive.gameObject.layer = 13; currentActive.gameObject.layer = 16; currentActive = cellToActive; currentActive.ChangeState(State.CONTROL); UIManager.uIManager.SwitchToClone(index); VariableContainer.variableContainer.currentActive = currentActive; }
private void ShootBasic(CellController cell, Vector2 direction, float shotLength, float chargeRate) { travelDistance = shotLength; this.cell = cell; if (cell.vars.faceLeft) { speed *= -1; } damageMultiplier = chargeRate; hasShot = true; }
public override void Shoot(CellController cell, Vector2 direction, float shotLength, float chargeRate) { base.Shoot(cell, direction, shotLength, chargeRate); RaycastHit2D hitInfo = Physics2D.Raycast(transform.position, direction, shotLength, wallMask); if (hitInfo) { travelDistance = hitInfo.distance; } hasShot = true; }
// Update is called once per frame private void Update() { for (int i = 0; i < clones.Count; i++) { CellController cellTemp = clones[i].GetComponent <CellController>(); if (cellTemp.vars.isDead && cellTemp.vars.isClone && cellTemp.vars.activeState != State.CONTROL) { DestroyInactiveClone(cellTemp); } } }
/// <summary> /// Code shared between all types of clone destruction /// </summary> /// <param name="cloneToKill">The desired clone to yeet</param> private void DestroyShared(CellController cloneToKill) { sfx.PlaySFX(1); clones.Remove(cloneToKill); ReturnPowerups(cloneToKill); mainCell.vars.activeClones--; mainCell.vars.maxHealth += 20; mainCell.vars.mainHealth += cloneToKill.vars.isGateClone ? 20 : 0; Destroy(cloneToKill.gameObject, CameraManager.cameraManager.cloneTransitionTime * 1.1f); UIManager.uIManager.SyncClones(); }
/// <summary> /// General method to creating a clone /// </summary> /// <param name="cellType">Type of clone selected from clone UI</param> private void CreateClone(CellType cellType) { sfx.PlaySFX(1); GameObject toInstantiate; switch (cellType) { case CellType.M_FIGHTER: toInstantiate = melee_fighter; break; case CellType.R_FIGHTER: toInstantiate = ranged_fighter; break; case CellType.JUMPER: toInstantiate = jumper; break; case CellType.SLINGER: toInstantiate = slinger; break; case CellType.GROUND: toInstantiate = ground; break; case CellType.NORMAL: default: toInstantiate = normal; break; } CellController newCell = (Instantiate <GameObject>(toInstantiate, mainCell.vars.isOnGate ? mainCell.vars.gateLocation.position + Vector3.up : mainCell.gameObject.transform.position, Quaternion.identity)).GetComponent <CellController>(); mainCell.vars.activeClones++; mainCell.vars.maxHealth -= 20; mainCell.vars.mainHealth = mainCell.vars.mainHealth > mainCell.vars.maxHealth ? mainCell.vars.maxHealth : mainCell.vars.mainHealth; index = 1; clones.Insert(index, newCell); currentActive.ChangeState(State.INACTIVE); SetActiveAndCam(newCell); currentActive.vars.type = cellType; GivePowerups(); currentActive.vars.isClone = true; UIManager.uIManager.SyncClones(); }
// Use this for initialization void Start() { mainCell = currentActive = GetComponent <CellController>(); VariableContainer.variableContainer.currentActive = currentActive; player = mainCell.player; cloneMenu.gameObject.SetActive(false); clones = new List <CellController>(6); clones.Add(mainCell); VariableContainer.variableContainer.cells = this.clones; }
public override void Shoot(CellController cell, Vector2 direction, float shotLength, float chargeRate) { travelDistance = shotLength; this.cell = cell; if (cell.vars.faceLeft) { speed *= -1; } if (cell.vars.equippedBullet == BulletType.CONE) { Vector2 cone1 = Vector2.zero; Vector2 cone2 = Vector2.zero; float rotation = 0; if (direction == Vector2.right) { cone1 = new Vector2(0.9659f, -0.2588f); cone2 = new Vector2(0.9659f, 0.2588f); } else if (direction == Vector2.left) { cone1 = new Vector2(-0.9659f, -0.2588f); cone2 = new Vector2(-0.9659f, 0.2588f); } else if (direction == Vector2.up) { cone1 = new Vector2(-0.2588f, 0.9659f); cone2 = new Vector2(0.2588f, 0.9659f); rotation = -90; } else { cone1 = new Vector2(0.2588f, -0.9659f); cone2 = new Vector2(-0.2588f, -0.9659f); rotation = 90; } (Instantiate(gameObject, transform.position, transform.rotation)).GetComponent <BaseBullet>().ShootBasic(cell, direction, shotLength, 0.8f); (Instantiate(gameObject, transform.position, Quaternion.Euler(new Vector3(0, 0, (rotation + 15) * (cell.vars.faceRight ? -1 : 1))))).GetComponent <BaseBullet>().ShootBasic(cell, cone1, shotLength, 0.55f); (Instantiate(gameObject, transform.position, Quaternion.Euler(new Vector3(0, 0, (rotation - 15) * (cell.vars.faceRight ? -1 : 1))))).GetComponent <BaseBullet>().ShootBasic(cell, cone2, shotLength, 0.55f); Destroy(gameObject); } else { damageMultiplier = (cell.vars.equippedBullet == BulletType.GHOST ? 0.8f : 1); hasShot = true; } }
/// <summary> /// General function to switch control between clones /// </summary> /// <param name="right">If true, indexes + 1, if false, indexes - 1</param> private void SwitchClone(bool right) { sfx.PlaySFX(0); index += right ? 1 : -1; if (index == clones.Count) { index = 0; } if (index < 0) { index = clones.Count - 1; } CellController newCell = clones[index]; currentActive.ChangeState(State.INACTIVE); SetActiveAndCam(newCell); }
public void SaveGame() { // autoSaveAnim.SetActive(true); CellController mainCell = VariableContainer.variableContainer ? VariableContainer.variableContainer.mainCell : FindObjectOfType <CellController>(); activeGame.cellData.SaveCellData(mainCell.vars); activeGame.RegenerateEnemies(); DataFormat dataFormat = DataFormat.JSON; byte[] bytes = SerializationUtility.SerializeValue(activeGame, dataFormat); using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Write)) using (var writer = new BinaryWriter(fs)) { writer.Write(bytes); } // autoSaveAnim.SetActive(false); }
void Awake() { if (variableContainer == null) { variableContainer = this; } else if (variableContainer != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); cells = new List <CellController>(); cells.AddRange(FindObjectsOfType <CellController>()); foreach (CellController c in cells) { if (!c.vars.isClone) { mainCell = c; } } currentActive = mainCell; }
/// <summary> /// Destroys a clone that is currently NOT in control /// </summary> /// <param name="cloneToKill">The desired clone to yeet</param> private void DestroyInactiveClone(CellController cloneToKill) { DestroyShared(cloneToKill); index = clones.IndexOf(currentActive); }
void Start() { hitObjects = new HashSet <GameObject>(); cell = GetComponentInParent <CellController>(); timer = TIMER; }
public void UpdateClone(CellController clone) { this.clone = clone; }
void Start() { cell = GetComponentInParent <CellController>(); }
public abstract void Shoot(CellController cell, Vector2 direction, float shotLength, float chargeRate);