Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
BanditArmActuator.cs
Go to the documentation of this file.
1 using System;
3 using UnityEngine;
4 
5 namespace droid.Runtime.Prototyping.Actuators {
9  [AddComponentMenu(ActuatorComponentMenuPath._ComponentMenuPath
10  + "BanditArm"
11  + ActuatorComponentMenuPath._Postfix)]
12  public class BanditArmActuator : Actuator {
13  [SerializeField] Material _material;
14 
18  public override string PrototypingTypeName { get { return "BanditArm"; } }
19 
22  protected override void Setup() {
23  var renderr = this.GetComponent<Renderer>();
24  if (renderr) {
25  this._material = renderr.sharedMaterial;
26  } else {
27  var rendr = this.GetComponent<CanvasRenderer>();
28  if (rendr) {
29  this._material = rendr.GetMaterial();
30  }
31  }
32  }
33 
39  protected override void InnerApplyMotion(IMotion motion) {
40  if (this._material) {
41  switch ((int)motion.Strength) {
42  case 1:
43  this._material.color = Color.blue;
44  break;
45  case 2:
46  this._material.color = Color.black;
47  break;
48  case 3:
49  this._material.color = Color.red;
50  break;
51  case 4:
52  this._material.color = Color.green;
53  break;
54  default:
55  throw new ArgumentOutOfRangeException();
56  }
57  }
58  }
59  }
60 }