Exemplo n.º 1
0
    void Start()
    {
        Player = GameObject.Find("Player");
        arm = Player.GetComponent<LimbController>();
        rgbd = GetComponent<Rigidbody2D>();
		playerScript = Player.GetComponent<Player>();
		temSpeed = playerScript.moveSpeed;
        playerAnimator = Player.GetComponent<Animator>();
		audioRock = this.gameObject.AddComponent<AudioSource>();
    }
Exemplo n.º 2
0
 void Start()
 {
     Player         = GameObject.Find("Player");
     arm            = Player.GetComponent <LimbController>();
     rgbd           = GetComponent <Rigidbody2D>();
     playerScript   = Player.GetComponent <Player>();
     temSpeed       = playerScript.moveSpeed;
     startPosition  = gameObject.transform.position;
     playerAnimator = Player.GetComponent <Animator>();
     audioRock      = this.gameObject.AddComponent <AudioSource>();
     temPosition    = gameObject.transform.position;
 }
Exemplo n.º 3
0
    private LimbController MakeLimbRoot(Transform ligament, Rigidbody parentRigidBody)
    {
        LimbController newLimbController   = ligament.gameObject.AddComponent <LimbController>();
        bool           newLigamentHasChain = ligament.TryGetComponent(out LigamentChain newLigamentChain);

        Assert.IsTrue(newLigamentHasChain);

        ConfigurableJoint configurableJoint = ligament.GetComponent <ConfigurableJoint>();

        configurableJoint.connectedBody = parentRigidBody;

        return(newLimbController);
    }
Exemplo n.º 4
0
    public virtual void CustomStart(string servoName, MemoryBridge memoryBridge, LimbController limbController, int parentID)
    {
        this.servoName      = servoName;
        gameObject.name     = servoName;
        this.limbController = limbController;

        this.memoryBridge = memoryBridge;

        limitMin = memoryBridge.GetFloat(servoName + "minPos");
        limitMax = memoryBridge.GetFloat(servoName + "maxPos");
        // Debug.Log(limitMax);

        if (servoName.ToLower().Contains("base"))
        {
            Debug.Log("Let limb base");
            limbControllerPart       = RoboticLimb.LimbPart.Base;
            limbController.servoBase = this;
        }
        else if (servoName.ToLower().Contains("wrist"))
        {
            limbControllerPart = RoboticLimb.LimbPart.Wrist;
        }

        if (servoName.ToLower().Contains("reverse"))
        {
            invert = true;
        }

        hostPart = GetComponent <Part>();
        hostPart.ServoAdded(this);

        lineRenderer = hostPart.lineRenderer;

        foreach (var part in hostPart.vessel.parts)
        {
            if (part.ID == parentID)
            {
                servoParent = part.servo;
                servoParent.SetChild(this);
            }
        }

        if (hostPart.name.ToLower().Contains("skip"))
        {
            DisableServo(true);
            Debug.Log(name + " disabled");
        }
    }
Exemplo n.º 5
0
	void Start()
	{
		//switchControl = GameObject.FindGameObjectWithTag("Player").GetComponent<SwitchControl>();
		moveSpeed = 10f;
		playerAnim = GameObject.FindGameObjectWithTag("Player").GetComponent<Animator>() as Animator;
		camScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraFollow>();
		facingRight = true;
		myBoxcollider = gameObject.GetComponent<BoxCollider2D>() as BoxCollider2D;
		myAnimator = GetComponent<Animator>();
		myController = GetComponent<Controller2D>();
		print("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);
		limbController = GetComponent<LimbController>();
		sounds = GetComponent<Sound>();
		playSound = false;
		myTarget = camScript.target;
		notOnNose = true;
	}
Exemplo n.º 6
0
 void Start()
 {
     //switchControl = GameObject.FindGameObjectWithTag("Player").GetComponent<SwitchControl>();
     moveSpeed     = 10f;
     playerAnim    = GameObject.FindGameObjectWithTag("Player").GetComponent <Animator>() as Animator;
     camScript     = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>();
     facingRight   = true;
     myBoxcollider = gameObject.GetComponent <BoxCollider2D>() as BoxCollider2D;
     myAnimator    = GetComponent <Animator>();
     myController  = GetComponent <Controller2D>();
     print("Gravity: " + gravity + "  Jump Velocity: " + maxJumpVelocity);
     limbController = GetComponent <LimbController>();
     sounds         = GetComponent <Sound>();
     playSound      = false;
     myTarget       = camScript.target;
     notOnNose      = true;
     needMove       = true;
 }
Exemplo n.º 7
0
    private Transform BuildCreature(Transform headTemplate)
    {
        Transform builtCreatureRoot = BuildHead(headTemplate);
        Rigidbody parentRigidNumber = builtCreatureRoot.GetComponent <Rigidbody>();

        int childCount = headTemplate.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform childTemplate = headTemplate.GetChild(i);

            if (childTemplate.TryGetComponent(out Ligament ligament))
            {
                Transform      newLigament       = BuildLigament(childTemplate, builtCreatureRoot);
                LimbController newLimbController = MakeLimbRoot(newLigament, parentRigidNumber);
                LigamentChain  endJoint          = BuildRestOfLimb(childTemplate, newLigament);

                newLimbController.BuildLimb(endJoint);
            }
        }

        return(builtCreatureRoot);
    }
Exemplo n.º 8
0
 protected override void Run()
 {
     listener = new TcpListener(IPAddress.Parse("127.0.0.1"), port);
     listener.Start();
     Debug.Log("is listening");
     while (true)
     {
         if (!listener.Pending())
         {
         }
         else
         {
             Debug.Log("socket comes");
             TcpClient     client = listener.AcceptTcpClient();
             NetworkStream ns     = client.GetStream();
             StreamReader  reader = new StreamReader(ns);
             msg = reader.ReadToEnd();
             ns.Close();
             Debug.Log(msg);
             LimbController.SetState(msg);// 将分类结果在unity中以动画的效果展示出来
             break;
         }
     }
 }
Exemplo n.º 9
0
 public virtual void CustomStart(LimbController limbController)
 {
     this.limbController = limbController;
 }
Exemplo n.º 10
0
	// Use this for initialization
	void Start () {
		Player = GameObject.Find ("Player");
		pickaxe = Player.GetComponent<LimbController> ();
        playerAnimator = Player.GetComponent<Animator>();
	}
Exemplo n.º 11
0
 private void Start()
 {
     _arm            = isLeft ? GamePad.Axis.LeftStick : GamePad.Axis.RightStick;
     _leg            = isLeft ? GamePad.Axis.RightStick : GamePad.Axis.LeftStick;
     _limbController = FindObjectOfType <LimbController>();
 }
Exemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     Player         = GameObject.Find("Player");
     pickaxe        = Player.GetComponent <LimbController> ();
     playerAnimator = Player.GetComponent <Animator>();
 }
 public override void CustomStart(LimbController limbController)
 {
     base.CustomStart(limbController);
 }