public void UnregisterAteObject(AteObject theObject) { if (theObject == null) { return; } // Check if key exists if (!_registeredAteObjects.ContainsKey(theObject.type)) { return; } // Remove object if necessary if (_registeredAteObjects[theObject.type].Contains(theObject)) { _registeredAteObjects[theObject.type].Remove(theObject); } // Remove key if necessary if (_registeredAteObjects[theObject.type].Count <= 0) { _registeredAteObjects.Remove(theObject.type); } }
public override void DrawInspector() { base.DrawInspector(); firer = EditorGUILayout.ObjectField ("Firer", firer, typeof(AteObject), true) as AteObject; projectilePrefab = EditorGUILayout.ObjectField ("Projectile Prefab", projectilePrefab, typeof(Projectile), false) as Projectile; projectileParent = EditorGUILayout.ObjectField ("Projectile Parent", projectileParent, typeof(Transform), true) as Transform; DrawTargetType(); fireStartVariance = EditorGUILayout.FloatField("Fire Start Variance", fireStartVariance); targetVariance = EditorGUILayout.FloatField("Target Variance", targetVariance); autoFireDelay = EditorGUILayout.FloatField("Autofire Delay", autoFireDelay); bool drawList = true; EditorHelper.DrawResizableList <Transform> ("Barrels", ref drawList, ref barrels, OnDrawBarrel); }
/// <summary> /// Adds an AteObject component to theObject. /// Also links up any AteComponents on theObject to use /// the new AteObject as an internal reference. /// If there is already an AteObject on theObject it /// will relink data but not make a new AteObject. /// </summary> private void ObjMod_AddAteObject(GameObject theObject) { // Get current AteObject or make a new one AteObject ateObj = theObject.GetComponent <AteObject> () as AteObject; if (ateObj == null) { ateObj = theObject.AddComponent <AteObject> () as AteObject; } // Set references between the AteObject and AteComponents ateObj.components.Clear(); AteComponent[] theComps = theObject.GetComponents <AteComponent> () as AteComponent[]; if (theComps != null) { for (int i = 0; i < theComps.Length; i++) { if (theComps[i] == null) { continue; } ateObj.components.Add(theComps[i]); theComps[i].SetMyObject(ateObj); } } // Move the AteObject up in the editor window to be at the top for (int i = 0; i < 10; i++) { UnityEditorInternal.ComponentUtility.MoveComponentUp(ateObj); } }
public void Fire(AteObject firer, Vector3 targetPos) { _targetDirection = Position.GetDir_To(targetPos, moveSpeed); if (faceTarget) { transform.LookAt(Position + _targetDirection); } _isFired = true; }
//TODO: This is supposed to be an entire modification system, not just ignoreArea stuff private void ModifyProjectile(AteObject firer, Projectile newProjectile) { CollisionArea projectileArea = newProjectile.GetComponent <CollisionArea> () as CollisionArea; if (projectileArea == null) { return; } CollisionArea firerArea = firer.GetComponent <CollisionArea> () as CollisionArea; if (firerArea == null) { return; } projectileArea.SetColliderIgnoreArea(firerArea); }
public void RegisterAteObject(AteObject theObject) { if (theObject == null) { return; } // Add key if necessary if (!_registeredAteObjects.ContainsKey(theObject.type)) { _registeredAteObjects.Add(theObject.type, new List <AteObject> ()); } // Add object if necessary if (!_registeredAteObjects[theObject.type].Contains(theObject)) { _registeredAteObjects[theObject.type].Add(theObject); } }