コード例 #1
0
 void CheckIfMoveFinished()
 {
     if (Vector3.Distance(startingPosition, transform.position) >= desiredDistance || Time.time > timeToEnd ||
         Time.time > timeOfStart + timeOut)
     {
         movementDesired = false;
         ControllScript.GetInstance().notifyRobotReady();
     }
 }
コード例 #2
0
 // Start is called before the first frame update
 void Start()
 {
     sensor = GetComponentInChildren <SensorSuite>();
     rigid  = GetComponent <Rigidbody>();
     Rotate(-30);
     gameObject.layer = Physics.IgnoreRaycastLayer;
     ControllScript.GetInstance().RegisterRobot(this);
     ControllScript.GetInstance().notifyRobotReady();
 }
コード例 #3
0
ファイル: GhostController.cs プロジェクト: TimoTheus27/ki-a3
    void OnDestroy()
    {
        try
        {
            Destroy(gameObject, .2f);

            ControllScript.GetInstance().DeRegisterGhost(this);
        }
        catch (System.Exception e)
        {
        }
    }
コード例 #4
0
 void Awake()
 {
     if (self)
     {
         Destroy(this);
     }
     else
     {
         self = this;
     }
     ghosts = new List <GhostController>();
 }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (rotationDesired)
        {
            rigid.AddTorque(0, currentTorque, 0);
            float virtualRotation        = transform.rotation.eulerAngles.y;
            float virtualDesiredRotation = desiredRotation;
            if (Mathf.Abs(lastFrameRotation - virtualRotation) > 50)
            {
                needsToCrossThreshold = false;
            }
            lastFrameRotation = virtualRotation;
            if (!needsToCrossThreshold && currentTorque > 0 && virtualRotation > virtualDesiredRotation)
            {
                rotationDesired = false;
                ControllScript.GetInstance().notifyRobotReady();
            }

            if (!needsToCrossThreshold && currentTorque < 0 && virtualRotation < virtualDesiredRotation)
            {
                rotationDesired = false;
                ControllScript.GetInstance().notifyRobotReady();
            }
        }

        if (!movementDesired)
        {
            return;
        }
        rigid.AddForce(transform.forward * desiredPower);
        if (rigid.velocity.magnitude > MaxVelocity)
        {
            rigid.velocity.Normalize();
            rigid.velocity *= MaxVelocity;
        }

        CheckIfMoveFinished();
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        keyScript         = gameObject.AddComponent <KeyScript>();
        tileManagerScript = gameObject.AddComponent <TileManagerScript>();
        mapManagerScript  = gameObject.AddComponent <MapManagerScript>();
        controllScript    = gameObject.AddComponent <ControllScript>();

        controllScript.enabled = false;
        keyScript.LoadKey();
        if (!mapManagerScript.IsDataFile("/mapki.dat"))
        {
            SaveMapsScript s = gameObject.AddComponent <SaveMapsScript>();
            mapManagerScript.LoadMaps(s.PrepareData());
        }
        else
        {
            mapManagerScript.LoadMaps("/mapki.dat");
        }

        buttonAction action = SetUpGame;

        gameMenuScript.SetUpLevelButtons(action);
        gameMenuScript.UpdateLevelButtons(keyScript.GetKeyValue());
    }
コード例 #7
0
ファイル: GhostController.cs プロジェクト: TimoTheus27/ki-a3
 void Start()
 {
     ControllScript.GetInstance().RegisterGhost(this);
 }
コード例 #8
0
 void OnDestroy()
 {
     self = null;
 }