/** * NotifyHarpoonControllersRemoveHookableObject removes the hookableObject from the harpoon controller * * @param hookableObject: object to remove */ private static void NotifyHarpoonControllersRemoveHookableObject(HookableObject hookableObject) { foreach (var harpoonController in HarpoonControllers) { harpoonController.NotifyRemoveHookableObject(hookableObject); } }
public void NotifyRemoveHookableObject(HookableObject hookableObject) { if (hookableObject.Equals(_objectHooked)) { _objectHooked = null; } }
void Spawn(GameObject spawnPrefab, int spawnIndex) { GameObject spawnedObject = Instantiate(spawnPrefab, spawnLocations[spawnIndex]); HookableObject hookableObject = spawnedObject.GetComponent <HookableObject>(); hookableObject.transform.parent = null; hookableObject.Initialize(); }
public virtual void DetachHook(HookableObject obj) { if (hookedItems.Contains(obj) == true) { HookMass -= obj.mass; hookedItems.Remove(obj); } }
public virtual void GrabHook(HookableObject obj) { if (hookedItems.Contains(obj) == false) { HookMass += obj.mass; hookedItems.Add(obj); } }
/** * * deletes a HookableObject at given position * * * * @param hookableObject delete reference of given hookableObject to free position */ public void DeleteHookableObject(HookableObject hookableObject) { var places = _spawnPlaces .Where(ContainsHookableObject) .Select(x => x.GetComponent <SpawnPlace>()) .Where(x => x.hookableObject.Equals(hookableObject)).ToList(); places.ForEach(x => x.hookableObject = null); }
/** * called on collision of HookableObject * * returns false if an object is already hooked * * @param hookableObject: object which collided * @param projectile which had collision */ public bool NotifyCollisionWithHookableObject(HookableObject hookableObject, GameObject collidedObject) { if (collidedObject.Equals(_projectileObj) && _objectHooked == null) { _objectHooked = hookableObject; return(true); } return(false); }
public HookableObject DetatchHookedObject() { HookableObject lastHookedObjected = hookedObject; reHookDelayTimer = Time.time + reHookDelay; hookedObject.UnHooked(); hookedObject = null; SetWeight(defaultMass); return(lastHookedObjected); }
private void OnTriggerEnter2D(Collider2D collision) { if (!hookedObject) { HookableObject hookableObject = collision.gameObject.GetComponent <HookableObject>(); if (hookableObject && !hookableObject.IsHooked && reHookDelayTimer < Time.time && hookableObject.IsActivated) { AttatchHookedObject(hookableObject); } } }
/// <summary> /// Adds and item to cargo if there is room /// </summary> /// <param name="size"></param> /// <returns>true if the task was successfull</returns> public bool AddItemToCargo(HookableObject item) { if (currentCargo + item.size <= maxCapacity) { cargoItems.Add(item); currentCargo += item.size; cargoMass += item.mass; playerRb.mass = copterMass + cargoMass; return(true); } else { return(false); } }
void OnCollisionEnter(Collision col) { if (m_HookState == HookState.Shooting) { if (col.gameObject.GetComponent <HookableObject>() != null) { m_Rigidbody.velocity = Vector3.zero; object_Hooked_On = col.gameObject.GetComponent <HookableObject>(); HitHookableObject(); } else { Debug.Log("Hit something, startretract"); StartRetracting(); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collidable) { HookableObject hookableObject = collision.gameObject.GetComponent <HookableObject>(); if (hookableObject) { if (myHook) { myHook.DetatchHookedObject(); } //if force > needed force Destroy(hookableObject.gameObject); Destroy(gameObject); //TODO apply force to objects } } }
/** * Called after Collision of HookableObject and Projectile * * @param hookableObject: object which is attached to projectile * @param projectileGameObject: projectile where hookableObject is attached to */ private static void AttachHookableObjectToProjectile(HookableObject hookableObject, GameObject projectileGameObject) { foreach (var harpoonController in HarpoonControllers) { // if there is a reason to hook stone, harpoon controller will return true if (harpoonController.NotifyCollisionWithHookableObject(hookableObject, projectileGameObject)) { GameObject.Find("StoneSpawner").GetComponent <HookableObjectSpawner>().DeleteHookableObject(hookableObject); hookableObject.SetTransformParent(projectileGameObject.transform); hookableObject.SetLayerToDraggableLayer(); //parent not needed right now hookableObject.SetParent(projectileGameObject); //TODO: change for implementation of Item!! //TODO this is ugly, dont do that. just to test code flow projectileGameObject.GetComponentInParent <Team>().AddStone(hookableObject.GetComponent <Stone>()); projectileGameObject.GetComponentInParent <Player>().AddStone(hookableObject.GetComponent <Stone>()); } } }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.transform.tag == "Crate") { HookableObject s = other.GetComponent <HookableObject>(); if (s != null) { s.SaveItem(); } } if (other.gameObject.transform.tag == "Copter") { EventManager.TriggerEvent(SaveStrings.eEnterPlatform); if (enterPlatform != null) { enterPlatform(gameObject); } if (canWin == true) { bool win = objectives.ObjectiveOneCompleted(); if (win == true && !once) { manager.winLevel(); once = true; } } //if (cargo.getCargoCrates() > 0) { // cargo.emptyCargo(); // other.GetComponent<CopterManagerTouch>().resetPower(); //} //if (other.GetComponent<CopterManagerTouch>().isHookDead == true) { // other.GetComponent<CopterManagerTouch>().isHookDead = false; //} } }
/** * returns Vector3 containing current position of HookableObject * * @param hookableObject HookableObject whose position is given */ public static Vector3 GetPositionOfHookableObject(HookableObject hookableObject) { return(hookableObject.GetPosition()); }
/** * set order in layer of HookableObjects SpriteRenderer * * @param hookableObject to change order of layer in * @param order int to set as order in layer */ public static void SetOrderInLayer(HookableObject hookableObject, int order) { hookableObject.SetOrderInLayer(order); }
private void AttatchHookedObject(HookableObject hookableObject) { hookedObject = hookableObject; hookableObject.GotHooked(this); SetWeight(hookableObject.mass); }
/** * handles OnWoundIn event, called by HarpoonController * * @param hookableObject object attached to projectile to be handled * @param inventory of player base where WoundIn event happened */ public static void OnWoundIn(HookableObject hookableObject, Inventory inventory) { hookableObject.OnWoundIn(inventory); }
/** * enable or disable colliderbox of HookableObject * * @param state bool to set * @param hookableObject HookableObject to set state in * */ public static void SetHookableObjectColliderState(HookableObject hookableObject, bool state) { hookableObject.SetColliderState(state); }