public void AddObject(ActivableObject obj) { int id = obj.GetInstanceID(); if (sceneObjects.ContainsKey(id)) { sceneObjects[id] = obj.Active; } else { sceneObjects.Add(id, obj.Active); } }
public List <ActivableObject> LookForActivables(List <Collider2D> iCols) { List <ActivableObject> activables = new List <ActivableObject>(); foreach (Collider2D col in iCols) { ActivableObject ao = col.gameObject.GetComponent <ActivableObject>(); if (!!ao) { activables.Add(ao); } } return(activables); }
// Ball collision with other objects private void OnTriggerEnter(Collider other) { //Check for a collision with an enemy Enemy potentialEnemy = other.GetComponent <Enemy>(); if (potentialEnemy != null && direction != Vector3.zero && triggerEnabled) { Enemy enemy = potentialEnemy; enemy.AddDamage(Mathf.RoundToInt(GameManager.i.ballManager.GetDamages() * damageModifier)); enemy.Slow(0.2f, 1); GameManager.i.momentumManager.IncrementMomentum(GameManager.i.momentumManager.momentumGainedPerEnemyHit); } //Check for a collision with a player (To pick the ball when it's on the ground) PlayerController potentialPlayer = other.GetComponent <PlayerController>(); if (potentialPlayer != null && canBePicked) { potentialPlayer.TakeBall(this, 0); } //Check for a collision with a player (Ball belong to an enemy and is "spiky") if (potentialPlayer != null && state == BallMoveState.Spiky) { potentialPlayer.Push(direction.normalized, 5); potentialPlayer.AddDamage(20); } //Check for a destructible object // TODO //Check for an activable Object ActivableObject potentialActObject = other.GetComponent <ActivableObject>(); if (potentialActObject != null) { potentialActObject.Activate(); //Diminish the Momentum of the value } }
void InitRayCast() { MessageCanvas.GetComponent <UnityEngine.UI.Text>().text = null; var hit = new RaycastHit(); if (Physics.Raycast(Eye.position, Eye.forward, out hit, 1.5f)) { Target = hit.transform; activable = Target.GetComponent <ActivableObject>(); if (activable != null) { if (Input.GetKeyUp(KeyCode.E)) { GameManager.instance.SetPhase(GamePhase.OnPlanet); } //Activable(Target); } } else { Target = null; } }