Example #1
0
    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;
                }
            }
        }
    }
Example #2
0
    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);
    }
Example #3
0
    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();
 }
Example #5
0
 private void Start()
 {
     animator      = GetComponentInChildren <Animator>();
     agent         = GetComponent <NavMeshAgent>();
     propertyBlock = new MaterialPropertyBlock();
     render        = GetComponentsInChildren <Renderer>();
     behavior      = GetComponentInChildren <RobotBehavior>();
     CurrentHealth = health;
 }
Example #6
0
    void OnUndo()
    {
        if (_activeRobot > -1)
        {
            RobotBehavior robot = robots[_activeRobot];

            Vector2Int lastPosition = robot.cellIndex;

            int step = robot.OnUndo();
            Resimulate(step, true);
        }
    }
Example #7
0
    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();
    }
Example #8
0
    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);
    }
Example #9
0
    // 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);
    }
Example #11
0
    // 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);
    }
Example #12
0
    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;
    }
Example #13
0
 // Start is called before the first frame update
 void Start()
 {
     instanceOfPrompt = GetComponent <TutorialPrompt>();
     _robotBehaviour  = robot.GetComponentInChildren <RobotBehavior>();
 }
Example #14
0
 void Start()
 {
     robotStart = robot.GetComponent <RobotBehavior>();
 }