public void setNewLink(RaycastHit pShapeHit, GameObject link) { clearLink(); // Set currentEffect to linked effect if (link.GetComponent <PhysicsEffect>()) { currentEffect = link.GetComponent <PhysicsEffect>(); currentEffect.PrimeEffect(pShapeHit); } else { if (link.GetComponentInChildren <ForceField>()) { currentEffect = link.GetComponentInChildren <ForceField>(); currentEffect.PrimeEffect(pShapeHit); } else if (link.GetComponentInChildren <OrbitalField>()) { currentEffect = link.GetComponentInChildren <OrbitalField>(); currentEffect.PrimeEffect(pShapeHit); } } GameObject newLink = Instantiate(link, currentCapturePivot); Transform newLinkTransform = newLink.transform; newLinkTransform.localScale = new Vector3(1, 1, 1); // Clamp size to always keep in view newLinkTransform.localPosition = Vector3.zero; newLinkTransform.gameObject.layer = LayerMask.NameToLayer(capturedLayer); traverseChildren(newLinkTransform); currentCapture = newLink; }
//Used to add to the effectedObjectList public void AddedEffectedObject(Rigidbody touchedObject, PhysicsEffect physicsEffect, GameObject attachedGameObject) { if (effectedObjectList.Count == 0) { EffectedObject effectedObject = new EffectedObject(Time.time, touchedObject, physicsEffect); effectedObjectList.Add(effectedObject); CreateAttachedGameObject(touchedObject, attachedGameObject); } else if ((effectedObjectList.Count > 0)) { bool checkIfExists = false; foreach (EffectedObject item in effectedObjectList) { if (item.touchedObject == touchedObject) { item.effectedTime = Time.time; checkIfExists = true; break; } } if (!checkIfExists) { EffectedObject effectedObject = new EffectedObject(Time.time, touchedObject, physicsEffect); effectedObjectList.Add(effectedObject); CreateAttachedGameObject(touchedObject, attachedGameObject); } } }
private void shoot(bool link, RaycastHit hit) { Collider col = hit.collider; PhysicsEffect physicsEffect = GetEffect(col.transform); // Links a Physics Shape, and stores its properties if (link) { if (col.CompareTag("PhysicsShape")) { ActiveEffectDisplay.instance.StoreEffectText(physicsEffect); CaptureManager.instance.setNewLink(hit, col.gameObject); // Does not hit field shapes } } // Shoots the stored properties into a PhysicsObject (Any regular object) else { //apply to player if (col.CompareTag("PhysicsShape")) { CaptureManager.instance.applyLink(hit, player); } //apply to object else if (col.CompareTag("PhysicsObject")) { CaptureManager.instance.applyLink(hit); } } }
//Apply Link for the player public void applyLink(RaycastHit hit, GameObject obj) { //if (currentEffect != null) //{ currentEffect = hit.transform.gameObject.GetComponent <PhysicsEffect>(); obj.GetComponent <EffectsManager>().AddEffect(hit, currentEffect, obj); //} }
public void RemoveEffect(PhysicsEffect effect) { if (currentEffects.ContainsKey(effect)) { effect.RemoveEffectedObj(this); currentEffects.Remove(effect); } }
public void UpdateMagnitude(PhysicsEffect effect) { if (currentEffects.ContainsKey(effect)) { TrackedEffect effectInfo = currentEffects[effect]; effect.ApplyEffect(effectInfo.hitInfo); // does not work for field shapes } }
// Add effect to player public void AddEffect(RaycastHit hitInfo, PhysicsEffect effect, GameObject player) { //Debug.Log("Effect: " + effect); //Does not work for Fields if (!currentEffects.ContainsKey(effect)) { if (!effect.isOneShotEffect) { currentEffects.Add(effect, new TrackedEffect(effect, hitInfo)); effect.AddEffectedObj(this); } effect.ApplyEffect(hitInfo, player); } }
public void AddEffect(RaycastHit hitInfo, PhysicsEffect effect) { //TODO prevents exact same effect from being added, but later we should make it so //if an updated version of an effect type is added, the original is removed etc. //Debug.Log("Effect: " + effect); //Does not work for Fields if (!currentEffects.ContainsKey(effect)) { if (!effect.isOneShotEffect) { currentEffects.Add(effect, new TrackedEffect(effect, hitInfo)); effect.AddEffectedObj(this); } effect.ApplyEffect(hitInfo); } }
public void StoreEffectText(PhysicsEffect effect) { this.effect = effect; }
public EffectedObject(float effectedTime, Rigidbody touchedObject, PhysicsEffect physicsEffect) { this.effectedTime = effectedTime; this.touchedObject = touchedObject; this.physicsEffect = physicsEffect; }
public TrackedEffect(PhysicsEffect effect, RaycastHit hitInfo) { this.effect = effect; this.hitInfo = hitInfo; }