Example #1
0
 public void AttackPlayer()
 {
     if (robotController.GetComponentInChildren <PlayerHealth>().curHealth > 0)
     {
         robotController.GetComponentInChildren <PlayerHealth>().DecreaseHealth(attackDamage);
     }
 }
Example #2
0
    public override Endeavour constructEndeavour(RobotController controller) {
		Battery battery = controller.GetComponentInChildren<Battery>();
		if (parent == null || battery == null) {
            return null;
        }
		RechargeAction action = new RechargeAction(controller, goals, parent, battery);
		action.rechargePoint = rechargePoint;
        return action;
    }
 protected override Endeavour createEndeavour(RobotController controller, Dictionary<TagEnum, Tag> tags)
 {
     Battery battery = controller.GetComponentInChildren<Battery>();
     if (battery == null) {
         return null;
     }
     RechargeAction action = new RechargeAction(this, controller, goals, tags, battery);
     action.rechargePoint = rechargePoint;
     return action;
 }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        anim.SetBool("isIdle", true);
        anim.SetBool("isWalking", false);

        anim.SetBool("isAttack", true);
        //anim.SetBool("isDead", true);

        if (Vector3.Distance(target.position, this.transform.position) < enguageDistance)
        {
            anim.SetBool("isIdle", false);

            Vector3 direction = target.position - this.transform.position;

            if (Mathf.Sign(direction.x) == 1 && facingLeft)
            {
                Flip();
            }
            else if (Mathf.Sign(direction.x) == -1 && !facingLeft)
            {
                Flip();
            }


            if (direction.magnitude >= attackDistance)
            {
                anim.SetBool("isWalking", true);

                Debug.DrawLine(target.transform.position, this.transform.position, Color.yellow);

                if (facingLeft)
                {
                    this.transform.Translate(Vector3.left * (Time.deltaTime * moveSpeed));
                }
                else if (!facingLeft)
                {
                    this.transform.Translate(Vector3.right * (Time.deltaTime * moveSpeed));
                }
            }

            if (direction.magnitude < attackDistance)
            {
                anim.SetBool("isAttack", true);
                Debug.DrawLine(target.transform.position, this.transform.position, Color.yellow);

                robotController.GetComponentInChildren <PlayerHeath>().currentHealth -= attackDamage;
            }
        }
        else if (Vector3.Distance(target.position, this.transform.position) > enguageDistance)
        {
            // do nothing
            Debug.DrawLine(target.position, this.transform.position, Color.green);
        }
    }
Example #5
0
    public override Endeavour constructEndeavour(RobotController controller)
    {
        Battery battery = controller.GetComponentInChildren <Battery>();

        if (parent == null || battery == null)
        {
            return(null);
        }
        RechargeAction action = new RechargeAction(controller, goals, parent, battery);

        action.rechargePoint = rechargePoint;
        return(action);
    }
	// Use this for initialization
	void Awake () {
		roboController = GetComponentInParent<RobotController> ();
        if (roboController == null) {
            Debug.LogWarning("Robot component '" + name + "' is not attached to a robot controller!");
        } else {
            powerSource = roboController.GetComponentInChildren<AbstractPowerSource>();

        }
        if (roboController == null) {
            Debug.LogWarning("Robot component '" + name + "' has no power source!");
        }

    }
 // Use this for initialization
 void Awake()
 {
     roboController = GetComponentInParent <RobotController> ();
     if (roboController == null)
     {
         Debug.LogWarning("Robot component '" + name + "' is not attached to a robot controller!");
     }
     else
     {
         powerSource = roboController.GetComponentInChildren <AbstractPowerSource>();
     }
     if (roboController == null)
     {
         Debug.LogWarning("Robot component '" + name + "' has no power source!");
     }
 }
Example #8
0
    void OnSceneGUI()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        Handles.BeginGUI();
        serializedObject.Update();
        RobotController robot   = (RobotController)target;
        Battery         battery = robot.GetComponentInChildren <Battery>();

        GUIStyle debugStyle = new GUIStyle(GUI.skin.textArea);

        debugStyle.font     = debugFont;
        debugStyle.fontSize = 14;
        GUIStyle debugLabelStyle = new GUIStyle(GUI.skin.label);

        debugLabelStyle.font     = debugFont;
        debugLabelStyle.fontSize = 14;

        Texture2D blue            = new Texture2D(1, 1);
        Color     transparentBlue = new Color(.1f, .1f, 1f, 1f);

        blue.SetPixel(0, 0, transparentBlue);
        blue.alphaIsTransparency = true;

        blue.Apply();

        Texture2D green            = new Texture2D(1, 1);
        Color     transparentGreen = new Color(.1f, 1f, .1f, 1f);

        green.SetPixel(0, 0, transparentGreen);
        green.alphaIsTransparency = true;

        green.Apply();

        Texture2D red            = new Texture2D(1, 1);
        Color     transparentRed = new Color(1f, .1f, .1f, 1f);

        red.SetPixel(0, 0, transparentRed);
        red.alphaIsTransparency = true;

        red.Apply();


        GUIStyle labelStyle = new GUIStyle(GUI.skin.label);

        labelStyle.font     = debugFont;
        labelStyle.fontSize = 14;

        GUIStyle blueStyle = new GUIStyle(GUI.skin.box);

        blueStyle.border = new RectOffset(0, 0, 0, 0);

        const float windowWidth    = 240f;
        const float verticalOffset = 42f;
        Rect        rectangle;

        if (battery != null)
        {
            rectangle = new Rect(5, 20, windowWidth, verticalOffset + 22f * robot.lines.Count + 44f);
        }
        else
        {
            rectangle = new Rect(5, 20, windowWidth, verticalOffset + 22f * robot.lines.Count);
        }
        GUILayout.Window(2, rectangle, (id) => {
            robot.shouldAlphabetize = GUILayout.Toggle(robot.shouldAlphabetize, "Alphabetize?");
            //GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(windowWidth)};
            for (int i = 0; i < robot.lines.Count; ++i)
            {
                DecisionInfoObject obj = robot.lines[i];

                GUILayoutOption[] boxOptions = new GUILayoutOption[] {
                    GUILayout.Width(100 * (obj.getPriority() / robot.maxPriority))
                };

                GUILayout.BeginHorizontal();
                GUIContent label = new GUIContent(obj.getTitle().PadRight(10));

                Vector2 labelSize = labelStyle.CalcSize(label);
                //GUILayoutOption[] labelOptions = new GUILayoutOption[] {
                //	GUILayout.Width(labelSize.x)
                //};
                float spaceBefore = 0;
                if (robot.maxPriority > 0)
                {
                    spaceBefore = 125;
                }
                else
                {
                    spaceBefore = 125 * ((robot.maxPriority + obj.getPriority()) / robot.maxPriority);
                }
                GUILayout.Space(spaceBefore);


                GUI.skin.box.normal.background = blue;
                GUILayout.Box(GUIContent.none, blueStyle, boxOptions);

                Rect checkBox = new Rect(5, i * 22 + verticalOffset, 15, 15);
                if (obj.isChosen())
                {
                    GUI.DrawTexture(checkBox, green);
                }
                else
                {
                    GUI.DrawTexture(checkBox, red);
                }

                GUI.Label(new Rect(30, i * 22 + verticalOffset, labelSize.x, labelSize.y), label.text, labelStyle);
                GUIContent priorityContent = new GUIContent(obj.getPriority().ToString("0.#0").PadLeft(7));
                GUI.Label(new Rect(labelSize.x + 115 - labelStyle.CalcSize(priorityContent).x / 2, i * 22 + verticalOffset, 200, labelSize.y), priorityContent, labelStyle);

                if (robot.maxPriority > 0)
                {
                    GUILayout.Space(100 * ((robot.maxPriority - obj.getPriority()) / robot.maxPriority));
                }
                else
                {
                    GUILayout.Space(100);
                }
                GUILayout.EndHorizontal();
            }

            if (battery != null)
            {
                battery.currentCapacity = GUILayout.HorizontalSlider(battery.currentCapacity, 0, battery.maximumCapacity);
                //GUILayout.BeginHorizontal(options);
                GUIContent zero   = new GUIContent("0");
                GUIContent cur    = new GUIContent(battery.currentCapacity.ToString("0.#0"));
                GUIContent max    = new GUIContent(battery.maximumCapacity.ToString());
                Vector2 labelSize = labelStyle.CalcSize(zero);
                GUI.Label(new Rect(5, (robot.lines.Count + 1) * 22 + verticalOffset, labelSize.x, labelSize.y), zero, labelStyle);
                labelSize = labelStyle.CalcSize(cur);
                GUI.Label(new Rect(windowWidth / 2 - labelSize.x / 2, (robot.lines.Count + 1) * 22 + verticalOffset, labelSize.x, labelSize.y), cur, labelStyle);
                labelSize = labelStyle.CalcSize(max);
                GUI.Label(new Rect(windowWidth - labelSize.x, (robot.lines.Count + 1) * 22 + verticalOffset, labelSize.x, labelSize.y), max, labelStyle);
            }
        }, robot.name);

        Handles.EndGUI();
    }
Example #9
0
 private void HealingPotion()
 {
     Debug.Log("Healing Potion!");
     robotController.GetComponentInChildren <PlayerHealth>().IncreaseHealth(20f);
 }