public void RelinquishControl(RobotBehavior robot) { if (_activeRobot > -1 && robot == robots[_activeRobot]) { SetControlledRobot(-1); if (_maxRobots < fruits.Count) { _maxRobots++; } _tick = -1; _nextAutoMove = Time.time + 0.1f; for (var i = 0; i < robotButtons.Count; i++) { if (i < _maxRobots) { robotButtons[i].interactable = true; } else { robotButtons[i].interactable = false; } } } }
bool Move(Vector2Int direction) { if (direction.x > 0) { lastMoveLeftRight = LRDirection.Right; } else if (direction.x < 0) { lastMoveLeftRight = LRDirection.Left; } RobotBehavior otherRobot = _gameManager.isCellBlockedByRobot(cellIndex + direction); if (otherRobot && otherRobot != this) { SetBroken(); otherRobot.isBroken = true; return(false); } previousCellIndex = cellIndex; cellIndex += direction; lastMoveTime = Time.time; return(true); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Target") { Debug.Log("Target hit!"); } else { Debug.Log("Something else hit"); Instantiate(Fire, transform.position, collision.gameObject.transform.rotation); Instantiate(Smoke, transform.position, collision.gameObject.transform.rotation); Vector3 explosionPos = transform.position; Collider[] colliders = Physics.OverlapSphere(explosionPos, radius); foreach (Collider hit in colliders) { Rigidbody rb = hit.GetComponent <Rigidbody>(); RobotBehavior behavior = hit.GetComponent <RobotBehavior>(); if (rb != null) { rb.AddExplosionForce(power, explosionPos, radius, 3.0F); if (behavior != null) { behavior.decreaseHealth(50); } } } } Destroy(gameObject); }
public void NewRobotBehavior() { currentRBehavior = new RobotBehavior(); currentRBehavior.Name = "RobotBehavior_" + robotBehaviorId.ToString(); robotBehaviorId++; robotStateId = 0; createBehaviorListScipt.ClearList(); }
private void Start() { animator = GetComponentInChildren <Animator>(); agent = GetComponent <NavMeshAgent>(); propertyBlock = new MaterialPropertyBlock(); render = GetComponentsInChildren <Renderer>(); behavior = GetComponentInChildren <RobotBehavior>(); CurrentHealth = health; }
void OnUndo() { if (_activeRobot > -1) { RobotBehavior robot = robots[_activeRobot]; Vector2Int lastPosition = robot.cellIndex; int step = robot.OnUndo(); Resimulate(step, true); } }
void Start() { fadeIn = GetComponent <FadeManager>(); fadeIn.StartCoroutine("CloseWindow"); robotStart = robot.GetComponent <RobotBehavior>(); audiosrc = GetComponent <AudioSource>(); startTimer = GetComponent <Timer>(); canvasGroup.alpha = 0; startText.SetActive(false); StartGame(); }
public void AddRobot(GameObject robotGameObject, Transform point) { combatManager.AddEntity(robotGameObject); RobotBehavior behavior = robotGameObject.GetComponentInChildren <RobotBehavior>(); behavior.SetTarget(target); behavior.SetSpawnpoint(point); behavior.InitializeRobot(this); EnemyHealth health = robotGameObject.GetComponent <EnemyHealth>(); health.InitializeRobot(this); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hits = Physics .RaycastAll(ray) .Select(h => h.transform.GetComponentInParent <RobotBehavior>()) .Where(r => r != null); if (hits.Any()) { this.SelectedRobot = hits.First(); } } this.TicksPerSecond = Mathf.Clamp(this.TicksPerSecond, 0, 100); }
// Start is called before the first frame update void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); this.animator = this.GetComponent <Animator>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.harvestRoutine = new SubRoutine { Name = "harvest", FullName = "arm.harvest", Owner = this.GetComponent <RobotPart>(), Fn = this.Harvest }; cpu.AddSubroutine(this.harvestRoutine); }
// Start is called before the first frame update void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.waterParticles.Pause(); this.waterRoutine = new SubRoutine { Name = "water", FullName = "arm.water", Owner = this.GetComponent <RobotPart>(), Fn = this.Water }; cpu.AddSubroutine(this.waterRoutine); }
private void Start() { this.robot = this.GetComponentInParent <RobotBehavior>(); this.game = GameObject.FindObjectOfType <GameManager>(); var chassis = this.GetComponentInParent <ChassisBehavior>(); var cpu = chassis.GetComponentInChildren <CpuBehavior>(); this.moveForward = new SubRoutine { Name = "move_forward", FullName = "leg.move_forward", Owner = this.GetComponent <RobotPart>(), Fn = this.MoveForward }; this.rotateLeft = new SubRoutine { Name = "rotate_left", FullName = "leg.rotate_left", Owner = this.GetComponent <RobotPart>(), Fn = this.RotateLeft }; this.rotateRight = new SubRoutine { Name = "rotate_right", FullName = "leg.rotate_right", Owner = this.GetComponent <RobotPart>(), Fn = this.RotateRight }; cpu.AddSubroutine(this.moveForward); cpu.AddSubroutine(this.rotateLeft); cpu.AddSubroutine(this.rotateRight); this.destination = robot.transform.position; }
// Start is called before the first frame update void Start() { instanceOfPrompt = GetComponent <TutorialPrompt>(); _robotBehaviour = robot.GetComponentInChildren <RobotBehavior>(); }
void Start() { robotStart = robot.GetComponent <RobotBehavior>(); }