//利用该函数,静态地从仍何存在的IControllable建立控制器 static public Controller From <T>(Existing <T> obj) where T : class, IControllable { return(new Controller( new Existing <IControllable>((IControllable)obj.Unwrap()) )); }
public void Watch(Existing <Bird> some_bird) { if (this.birdUnderWatch == null) { this.birdUnderWatch = some_bird.Unwrap(); Debug.Log("Watch bird"); } }
//load the bird onto SlingShot. The slingshot's bullet cannot be NULL!!! //The existence simplify the implemantation. It ensures the load to change states. public void Load(Existing <Bird> bullet) { //since the bullet reflects the state, this ensures call only works under unloaded state if (!this.IsLoaded) { this.bullet = bullet.Unwrap(); this.bullet.physicsLock = true; this.bullet.transform.position = new Vector3( positioner.position.x, positioner.position.y, this.bullet.transform.position.z ); } }
//为控制器绑定新的可控制对象 public void BindsTo <T>(Existing <T> obj) where T : class, IControllable { this.control = (IControllable)obj.Unwrap(); }
Controller(Existing <IControllable> control) { this.control = control.Unwrap(); }
private void Kill(Existing <Bird> bird) { bird.Unwrap().isDead = true; }