public override BlobState AssignBlob(BlobBase blob) { var state = base.AssignBlob(blob); blob.StartInteracting(this); return(state); }
private IEnumerator CallBlobsBack() { float callRange = 0f; while (true) { callRange += rangeGrowthPerSeconds * Time.deltaTime; callRange = Mathf.Clamp(callRange, 0f, maxCallRange); nearbyBlobs = Physics.SphereCastAll(transform.position, callRange, Vector3.up, 0f, blobLayerMask); foreach (var blobHit in nearbyBlobs) { BlobBase blob = blobHit.collider.GetComponent <BlobBase>(); if (blob == null || !blob.CanBeCalled()) { continue; } if (followingBlobs.Count < maxFollowers) { AddBlobToFollowers(blob); } } callIndicator.transform.localScale = new Vector3(callRange * 2, callRange * 2, callRange * 2); yield return(null); } }
public override Vector3 GetBlobOffset(BlobBase blob) { float angle = assignedBlobs.Count * Mathf.PI * 2f / blobsNeeded; float distanceToCenter = Random.Range(0f, radius); return(new Vector3(Mathf.Cos(angle) * distanceToCenter, 0, Mathf.Sin(angle) * distanceToCenter)); }
public override BlobState AssignBlob(BlobBase blob) { var state = base.AssignBlob(blob); blob.StartFighting(destructable); return(state); }
public override BlobState AssignBlob(BlobBase blob) { var state = base.AssignBlob(blob); blob.transform.SetParent(transform); blob.transform.position = transform.position + GetBlobOffset(blob); UpdateCarrySpeed(); return(state); }
public override void RemoveBlob(BlobBase blob) { if (blob == null) { return; } base.RemoveBlob(blob); blob.transform.SetParent(null); }
public override bool CanBeAssigned(BlobBase blob) { if (assignedBlobs.Count >= conductorPlates.Length) { return(false); } return(blob.GetType() == typeof(ConductorBlob)); }
public override void RemoveBlob(BlobBase blob) { base.RemoveBlob(blob); if (occupiedPlates.ContainsKey(blob)) { occupiedPlates[blob].IsOccupied = false; occupiedPlates.Remove(blob); } }
public virtual void RemoveBlob(BlobBase blob) { assignedBlobs.Remove(blob); display.AssignedBlobs = assignedBlobs.Count; blob.State = BlobState.Idle; if (assignedBlobs.Count < blobsNeeded && InteractionHasStarted) { StopInteraction(); } }
public virtual BlobState AssignBlob(BlobBase blob) { assignedBlobs.Add(blob); display.AssignedBlobs = assignedBlobs.Count; if (assignedBlobs.Count >= blobsNeeded && !InteractionHasStarted) { StartInteraction(); } return(interactorState); }
public void SendBlobToTube(PneumaticTube tube) { if (followingBlobs.Count <= 0) { return; } BlobBase blob = followingBlobs.First(); followingBlobs.Remove(blob); blob.StartFollowing(tube.transform); blob.State = BlobState.GoingToTube; }
bool IsColorNearby(GameObject objectCurrentlySelected) { List <GameObject> neighbours = grid.GetNeighbours(objectCurrentlySelected.transform.position); for (int i = 0; i < neighbours.Count; i++) { BlobBase blobBase = neighbours[i].GetComponentInChildren <BlobBase>(); if (neighbours[i] != null && blobBase != null && blobBase.colorID != null) { if (blobBase.colorID == matchID) { return(true); } } } return(false); }
public override Vector3 GetBlobOffset(BlobBase blob) { if (occupiedPlates.ContainsKey(blob)) { return(occupiedPlates[blob].transform.localPosition); } foreach (var plate in conductorPlates) { if (!plate.IsOccupied) { plate.IsOccupied = true; occupiedPlates.Add(blob, plate); return(plate.transform.localPosition); } } Debug.LogWarning("Trying to assign more blobs to a circuit than there are plates"); return(Vector3.zero); }
private IEnumerator ThrowBlobs() { while (followingBlobs.Count > 0) { if (throwTargetPosition == Vector3.negativeInfinity) { yield return(null); } playerAnimator.SetTrigger("Fire"); BlobBase blob = followingBlobs.First(); followingBlobs.Remove(blob); blob.GetThrown(transform.position, throwTargetPosition); yield return(new WaitForSeconds(timeBetweenThrows)); } StopCurrentAction(); }
public virtual Vector3 GetBlobOffset(BlobBase blob) { float angle = assignedBlobs.Count * Mathf.PI * 2f / blobsNeeded; return(new Vector3(Mathf.Cos(angle) * radius, 0, Mathf.Sin(angle) * radius)); }
private void UpdateParameterValues() { int index = -1; for (int i = 0; i < this.statement.Parameters.Count; i++) { index = i; if (this.namedParameters.Count > 0) { index = this.parameters.IndexOf(this.namedParameters[i]); } if (index != -1) { if (this.parameters[index].Value == DBNull.Value || this.parameters[index].Value == null) { this.statement.Parameters[i].NullFlag = -1; this.statement.Parameters[i].Value = DBNull.Value; if (!this.statement.Parameters[i].AllowDBNull()) { this.statement.Parameters[i].DataType++; } } else { // Parameter value is not null this.statement.Parameters[i].NullFlag = 0; switch (this.statement.Parameters[i].DbDataType) { case DbDataType.Binary: { BlobBase blob = this.statement.CreateBlob(); blob.Write((byte[])this.parameters[index].Value); this.statement.Parameters[i].Value = blob.Id; } break; case DbDataType.Text: { BlobBase blob = this.statement.CreateBlob(); blob.Write((string)this.parameters[index].Value); this.statement.Parameters[i].Value = blob.Id; } break; case DbDataType.Array: { if (this.statement.Parameters[i].ArrayHandle == null) { this.statement.Parameters[i].ArrayHandle = this.statement.CreateArray( this.statement.Parameters[i].Relation, this.statement.Parameters[i].Name); } else { this.statement.Parameters[i].ArrayHandle.DB = this.statement.DB; this.statement.Parameters[i].ArrayHandle.Transaction = this.statement.Transaction; } this.statement.Parameters[i].ArrayHandle.Handle = 0; this.statement.Parameters[i].ArrayHandle.Write((System.Array) this.parameters[index].Value); this.statement.Parameters[i].Value = this.statement.Parameters[i].ArrayHandle.Handle; } break; case DbDataType.Guid: if (!(this.parameters[index].Value is Guid) && !(this.parameters[index].Value is byte[])) { throw new InvalidOperationException("Incorrect Guid value."); } this.statement.Parameters[i].Value = this.parameters[index].Value; break; default: this.statement.Parameters[i].Value = this.parameters[index].Value; break; } } } } }
public override bool CanBeAssigned(BlobBase blob) { return(blob.GetType() == typeof(RockBlob)); }
public void AddBlobToFollowers(BlobBase blob) { blob.StartFollowing(followerTarget); followingBlobs.Add(blob); blob.controller = this; }
public void RemoveBlobFromFollowers(BlobBase blob) { followingBlobs.Remove(blob); }
private void UpdateParameterValues() { int index = -1; for (int i = 0; i < _statement.Parameters.Count; i++) { var statementParameter = _statement.Parameters[i]; index = i; if (_namedParameters.Count > 0) { index = Parameters.IndexOf(_namedParameters[i], i); if (index == -1) { throw new FbException(string.Format("Must declare the variable '{0}'", _namedParameters[i])); } } if (index != -1) { var commandParameter = Parameters[index]; if (commandParameter.InternalValue == DBNull.Value || commandParameter.InternalValue == null) { statementParameter.NullFlag = -1; statementParameter.Value = DBNull.Value; if (!statementParameter.AllowDBNull()) { statementParameter.DataType++; } } else { statementParameter.NullFlag = 0; switch (statementParameter.DbDataType) { case DbDataType.Binary: { BlobBase blob = _statement.CreateBlob(); blob.Write((byte[])commandParameter.InternalValue); statementParameter.Value = blob.Id; } break; case DbDataType.Text: { BlobBase blob = _statement.CreateBlob(); if (commandParameter.InternalValue is byte[]) { blob.Write((byte[])commandParameter.InternalValue); } else { blob.Write((string)commandParameter.InternalValue); } statementParameter.Value = blob.Id; } break; case DbDataType.Array: { if (statementParameter.ArrayHandle == null) { statementParameter.ArrayHandle = _statement.CreateArray( statementParameter.Relation, statementParameter.Name); } else { statementParameter.ArrayHandle.DB = _statement.Database; statementParameter.ArrayHandle.Transaction = _statement.Transaction; } statementParameter.ArrayHandle.Handle = 0; statementParameter.ArrayHandle.Write((System.Array)commandParameter.InternalValue); statementParameter.Value = statementParameter.ArrayHandle.Handle; } break; case DbDataType.Guid: if (!(commandParameter.InternalValue is Guid) && !(commandParameter.InternalValue is byte[])) { throw new InvalidOperationException("Incorrect Guid value."); } statementParameter.Value = commandParameter.InternalValue; break; default: statementParameter.Value = commandParameter.InternalValue; break; } } } } }
public static void ForgetBlob(BlobBase blob) { instance.blobsInField.Remove(blob); }
public static void RememberBlob(BlobBase blob) { instance.blobsInField.Add(blob); }
public virtual bool CanBeAssigned(BlobBase blob) { return(true); }
private void SetInputParameter( short index, short childPos, ParameterDirection paramDir, BdpType dataType, BdpType subType, int maxPrecision, int maxScale, int length, object value, bool isNullable) { // Set null flag if (value == null || value == DBNull.Value) { this.statement.Parameters[index].NullFlag = -1; this.statement.Parameters[index].Value = DBNull.Value; } else { this.statement.Parameters[index].NullFlag = 0; // Set parameter value switch (this.statement.Parameters[index].DbDataType) { case DbDataType.Array: if (this.statement.Parameters[index].ArrayHandle == null) { this.statement.Parameters[index].ArrayHandle = this.statement.CreateArray( this.statement.Parameters[index].Relation, this.statement.Parameters[index].Name); } else { this.statement.Parameters[index].ArrayHandle.DB = this.statement.DB; this.statement.Parameters[index].ArrayHandle.Transaction = this.statement.Transaction; } this.statement.Parameters[index].ArrayHandle.Handle = 0; this.statement.Parameters[index].ArrayHandle.Write((System.Array)value); this.statement.Parameters[index].Value = this.statement.Parameters[index].ArrayHandle.Handle; break; case DbDataType.Binary: BlobBase blob = this.statement.CreateBlob(); blob.Write((byte[])value); this.statement.Parameters[index].Value = blob.Id; break; case DbDataType.Text: BlobBase clob = this.statement.CreateBlob(); if (value is char[]) { clob.Write(new String((char[])value)); } else { clob.Write((string)value); } this.statement.Parameters[index].Value = clob.Id; break; default: this.statement.Parameters[index].Value = value; break; } } }