// Use this for initialization void Start() { currentState = State.Idle; currentSecondaryState = SecondaryState.Idle; currentResearchProtocol = 0; //Get own rigidbody component. rb = this.GetComponent <Rigidbody>(); // Get own movement controller fishMovementController = GetComponent <FishMovementController>(); StatusIcon.enabled = false; PanicBarRect.gameObject.SetActive(false); panicBarWidth = PanicBarRect.rect.width; panicTimer = GameData.GetFishParameters(fishType).panicTimerLength; currentPanicRate = slowPanicRate; if (fishType != GameData.FishType.None) { fishRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); Setup(); } SetEnabled(false); }
/// <summary> /// This function will add the SecondaryState "state" to the SecondaryState list if they list does not aleady /// include that state. /// </summary> /// <param name="state">The SecondaryState to be added to the SecondaryState list.</param> public void addSecondaryState(SecondaryState state) { if (!(secondaryStates.IndexOf(state) >= 0)) { secondaryStates.Add(state); } }
// Update is called once per frame void Update() { switch (currentSecondaryState) { case SecondaryState.Idle: break; case SecondaryState.Dead: break; case SecondaryState.Researched: case SecondaryState.Panic: panicTimer -= Time.deltaTime * currentPanicRate; if (panicTimer <= 0) { currentSecondaryState = SecondaryState.Dead; panicTimer = 0f; StatusIcon.sprite = deadSprite; StatusIcon.enabled = true; } PanicBarRect.sizeDelta = new Vector2(panicBarWidth * panicTimer / GameData.GetFishParameters(fishType).panicTimerLength, PanicBarRect.rect.height); break; default: break; } }
public void PickUpObject(GameObject other) { if (GetCurrentState() != State.PickingUp) { SetAttachObject(other, true); currentSecondaryState = SecondaryState.Idle; } }
public void DropObject() { if (GetCurrentState() != State.PickingUp) { SetAttachObject(heldObject, false); heldObject = null; currentSecondaryState = SecondaryState.Idle; } }
// Use this for initialization void Start() { currentState = State.Idle; currentSecondaryState = SecondaryState.Idle; anim = GetComponentInChildren <Animator>(); // Set in the editor //player = gameObject; //player = FindComponent<PlayerController>(); //holdSlot = gameObject.transform.Find("HoldSlot").gameObject; heldObject = null; }
/// <summary> /// This function will remove the SecondaryState "state" from the seconday state list. /// </summary> /// <param name="state">The SecondaryState to be removed.</param> /// <returns>Returns true if "state" was in the SecondaryState list. False if it was not.</returns> public bool removeSecondaryState(SecondaryState state) { int i = secondaryStates.IndexOf(state); if (i >= 0) { secondaryStates.RemoveAt(i); return(true); } return(false); }
/// <summary> /// </summary> /// <param name="state"></param> /// <returns>Returns true if "state" exists in the States list of SecondaryStates.</returns> public bool inState(SecondaryState state) { foreach (SecondaryState s in secondaryStates) { if (s == state) { return(true); } } return(false); }
void OnTriggerExit(Collider other) { if (other.tag == "FishObject" || other.tag == "StationObject") { if (other.gameObject == atObject) { currentSecondaryState = SecondaryState.Idle; HighlightObject(atObject, false); atObject = null; } } }
void OnTriggerStay(Collider other) { if (currentSecondaryState != SecondaryState.View) { if (other.tag == "FishObject" || other.tag == "StationObject") { atObject = other.gameObject; HighlightObject(atObject, true); currentSecondaryState = SecondaryState.View; } } }
public void ResearchFish() { //Eventually move this color change thing to a ResearchProtocolController. researchProtocols [currentResearchProtocol].complete = true; currentResearchProtocol++; if (currentResearchProtocol >= researchProtocols.Length) { panicTimer = GameData.GetFishParameters(fishType).panicTimerLength; currentPanicRate = slowPanicRate; currentResearchProtocol = researchProtocols.Length; currentSecondaryState = SecondaryState.Researched; StatusIcon.sprite = researchedSprite; StatusIcon.enabled = true; GameData.AddResearchedFish(fishType); } }
public void PickUp() { if (rb) { rb.isKinematic = true; rb.detectCollisions = false; } currentState = State.Held; if (currentPanicRate == floorPanicRate) { currentPanicRate = previousPanicRate; } if (currentSecondaryState == SecondaryState.Idle) { currentSecondaryState = SecondaryState.Panic; PanicBarRect.gameObject.SetActive(true); } }
public bool IsActiveState(TerrainType type, ref IState successorState) { switch (type) { case TerrainType.Standard: throw new Exception("Illegal Terrain"); case TerrainType.Convex: successorState = new PrimaryState(); return(true); case TerrainType.Wall: return(true); case TerrainType.Concave: successorState = new SecondaryState(); return(true); } return(false); }
/// <summary> /// This function will remove the SecondaryState "state" from the seconday state list. /// </summary> /// <param name="state">The SecondaryState to be removed.</param> /// <returns>Returns true if "state" was in the SecondaryState list. False if it was not.</returns> public bool removeSecondaryState(SecondaryState state) { int i = secondaryStates.IndexOf(state); if (i >= 0) { secondaryStates.RemoveAt(i); return true; } return false; }
/// <summary> /// </summary> /// <param name="state"></param> /// <returns>Returns true if "state" exists in the States list of SecondaryStates.</returns> public bool inState(SecondaryState state) { foreach (SecondaryState s in secondaryStates) { if (s == state) { return true; } } return false; }