void CreateObstacle(Collectible.Type type, GridPosition pos) { var newObstacle = new Interractable(gameAtlas, type); newObstacle.MoveTo(pos); Target.Add(newObstacle); }
void CreateObstacle(Collectible.Type type, int x, int y) { var newObstacle = new Interractable(atlas, type); newObstacle.MoveTo(x, y); obstacles.Add(newObstacle); }
public void removeForInterraction(Interractable x) { if (interractablesUpClose.Contains(x)) { interractablesUpClose.Remove(x); } }
private void OnCollisionEnter(UnityEngine.Collision collision) { if (collision.collider is SphereCollider) { Interractable itOther = collision.collider.GetComponentInParent <Interractable>(); if (itOther != null) { if (itOther.isFire) { Interractable it = gameObject.GetComponent <Interractable>(); if (it != null) { if (it.inflamAble) { if (collision.gameObject.GetComponent <InflamAble>().OnFire) { if (!OnFire) { GameObject.Find("LocalGameSystem").GetComponent <UNETSyncObjects>().add(gameObject, ToDo.setFire, "true"); //OnFire = true; } } } } } } } }
//calculates which interractable object is closer to the character and returns the index of the closer one for further interraction private Interractable decideFromInterractionList() { Interractable ret = null; int ind = 0; float min = 90000.0f; foreach (var item in interractablesUpClose) { float temp = Mathf.Abs(item.self.transform.position.x - self.transform.position.x) + Mathf.Abs(item.self.transform.position.y - self.transform.position.y); if (min > temp) { min = temp; ret = item; } ind++; } return(ret); }
public void RemoveAt(int index) { if (!walls[index]) { Collectible dItem = null; foreach (var item in items) { if (item.Index == index) { dItem = item; } } items.Remove(dItem); if (dItem != null) { if (dItem.type == Collectible.Type.HEART) { dItem.OnDeath -= EndLevel; } dItem.Kill(); } Interractable dObstacle = null; foreach (var item in obstacles) { if (item.Index == index) { dObstacle = item; } } obstacles.Remove(dObstacle); if (dObstacle != null) { dObstacle.Kill(); } } }
public void addForInterraction(Interractable x) { interractablesUpClose.Add(x); }
// Update is called once per frame void Update() { if (isLocalPlayer) { if (!inInterraction) { /* * if (objetTouche != null) * { * if (!objetTouche.GetComponent<Interractable>().interract) * { * free(); * } * } * Vector3 startPosition = ObjstartPosition.transform.position; * Vector3 direction = viseur.transform.TransformDirection(Vector3.forward) * tailleRayon; * Debug.DrawRay(startPosition, direction, Color.green); * * RaycastHit hit; * if (Physics.Raycast(startPosition, direction, out hit)) * { * if (hit.transform.tag == "Interractable" && hit.distance < tailleRayon) * { * if (!hit.transform.GetComponent<Interractable>().interract) * { * afficheNom(hit.transform.GetComponent<Interractable>().displayName, 2); * objetTouche = hit.transform.gameObject; * } * } * } */ } if (Input.GetKey(KeyCode.E)) { if (objetTouche != null) { if (objetTouche.GetComponent <Interractable>().pickable&& objetTouche == heavyBox) { GetComponent <PlayerController>().anim.SetFloat("Idle", 3); GetComponent <PlayerController>().anim.SetFloat("Walk", 2); } } } if (Input.GetKeyDown(KeyCode.E)) { if (objetTouche != null) { Interractable inter = objetTouche.GetComponent <Interractable>(); NetworkInstanceId myNetID = GetComponent <NetworkIdentity>().netId; if (inter.pickable && objetTouche == heavyBox) { heavyBox.GetComponent <CasseCaisse>().incrPlayer(); heavyBox.GetComponent <CasseCaisse>().slice(); } if (inter.moveAble && inter.pickable) { GameObject.Find("Obj_transporte").GetComponent <Text>().text = inter.interract ? "" : inter.displayName; if (!inter.interract) { afficheNom("", 0); } inter.player = inter.interract ? null : gameObject; modifications.add(objetTouche, inter.interract ? NetworkInstanceId.Invalid : myNetID, ToDo.move); inInterraction = !inter.interract; } if (inter.sliceAble) { modifications.add(objetTouche, myNetID, ToDo.slice); afficheNom("", 0); inter.player = gameObject; inInterraction = true; } if (inter.clickAble) { objetTouche.GetComponent <Action>().click(); } if (inter.rollAble) { modifications.add(objetTouche, myNetID, ToDo.roll); afficheNom("", 0); inter.player = gameObject; inInterraction = true; } if (inter.readAble) { objetTouche.GetComponent <ReadAble>().Activate(objetTouche); objetTouche.GetComponent <ReadAble>().Activate(GetComponent <PlayerComponents>().obj[0]); } } } if (Input.GetKeyUp(KeyCode.E)) { GetComponent <PlayerController>().anim.SetFloat("Idle", 0); GetComponent <PlayerController>().anim.SetFloat("Walk", 0); if (objetTouche != null) { Interractable inter = objetTouche.GetComponent <Interractable>(); if (objetTouche == heavyBox) { heavyBox.GetComponent <CasseCaisse>().decrPlayer(); heavyBox.GetComponent <CasseCaisse>().slice(); } if (inter.sliceAble) { objetTouche.GetComponent <Interractable>().player = null; modifications.add(objetTouche, NetworkInstanceId.Invalid, ToDo.slice); objetTouche = null; inInterraction = false; } if (inter.rollAble) { objetTouche.GetComponent <Interractable>().player = null; modifications.add(objetTouche, NetworkInstanceId.Invalid, ToDo.roll); objetTouche = null; inInterraction = false; } } } } }
public void Add(Interractable obstacle) { walls[obstacle.Index] = false; RemoveAt(obstacle.Index); obstacles.Add(obstacle); }