Ejemplo n.º 1
0
    private void FocusCameraOnSubsystem(Camera c, ShipSubsystem sub)
    {
        Vector3 pos = sub.transform.InverseTransformPoint(sub.transform.position);
        pos.z = pos.z + 0.35f;
        pos =  sub.transform.TransformPoint(pos);

        c.transform.position = pos;
        c.transform.LookAt(sub.transform.position,sub.transform.up);

        focusedPanel = sub;
    }
Ejemplo n.º 2
0
    void ProcessGameInput()
    {
        targetVelocity = Vector3.zero;

        if (GetAction(ActionCode.shipMenu))
        {
            //Debug.Log("Escape");
            mode = controlMode.menu;
            focusedPanel = null;
            Camera c =GameObject.Find("ShipCamera").GetComponent<Camera>();
            c.transform.position = system["Body"].transform.FindChild("MountPilot").position;
            c.transform.rotation = system["Body"].transform.FindChild("MountPilot").rotation;
        }

        if (GetAction(ActionCode.viewToggle))
        {
            focusedPanel = null;
            Camera c =GameObject.Find("ShipCamera").GetComponent<Camera>();
            c.transform.position = system["Body"].transform.FindChild("MountPilot").position;
            c.transform.rotation = system["Body"].transform.FindChild("MountPilot").rotation;

            if(mode == controlMode.sensor)
            {
                mode = controlMode.manual;
            }
            else
            {
                mode = controlMode.sensor;
            }
        }

        if (mode == controlMode.menu)
            return;

        if(	mode == controlMode.sensor)
        {
            targetVelocity = CalculateTargetVelocity2d();
            //targetPos.y = 4; // Here is where we adjust to keep on the path's plane
            //targetPos = targetPos - ship.transform.position;
            if ((GetAction(ActionCode.left)||
                 GetAction(ActionCode.right)||
                 GetAction(ActionCode.forward)||
                 GetAction(ActionCode.backward))
                || targetVelocity.magnitude > 1f)
            {
                targetVelocity = targetVelocity;
            }
            else
            {
                targetVelocity = Vector3.zero ;
            }
        }
        if(	mode == controlMode.manual)
        {

            Vector3 theForward = ship.transform.forward;
            Vector3 theUp = ship.transform.up;
            Vector3 theRight = Vector3.Cross(theUp,theForward);
            Vector3 theLeft = (-1)*theRight;

            if (GetAction(ActionCode.left))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist*theLeft;
            if (GetAction(ActionCode.right))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist*theRight;
            if (GetAction(ActionCode.forward))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist* theForward;
            if (GetAction(ActionCode.backward))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist*(-1)* theForward;
            if (GetAction(ActionCode.up))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist* theUp;
            if (GetAction(ActionCode.down))
                targetVelocity = targetVelocity + SRLConfiguration.P_mvdist*(-1)* theUp;

            if(targetVelocity == Vector3.zero)
            {
                Vector3 currVeloOff = ship.GetComponent<Rigidbody>().velocity -
                    Vector3.Project(ship.GetComponent<Rigidbody>().velocity,theForward);
                Vector3 currVeloOn = Vector3.Project(ship.GetComponent<Rigidbody>().velocity,theForward);

                targetVelocity = -currVeloOff +
                    targetFwdVelocity.magnitude*theForward - currVeloOn;
            }
            else
            {
                targetFwdVelocity = Vector3.Project(ship.GetComponent<Rigidbody>().velocity,theForward);
            }

            targetVelocity = targetVelocity;
        }
    }
Ejemplo n.º 3
0
    protected override void Initalize()
    {
        rotateSign = 1;
        avatarPoint = Vector3.zero;
        targetFwdVelocity = Vector3.zero;
        g_displayName = "Human Player Interface";
        this.g_displayDescription = "Retrieves information from the player object.";
        this.g_activeEnergyCost = 0;
        this.g_activeMetalCost = 0;
        this.g_activeOxygenCost = 0;
        this.g_criticalSystem = true;
        this.g_status = Status.active;
        this.g_showOnPanel = false;
        this.g_maxEnergy = 0;
        this.g_maxMetal = 0;
        this.g_maxOxygen = 0;
        this.g_maxHealth = 1;
        this.g_health = 1;
        InitCommandStatus ();

        cursorPos = Vector3.zero;

        focusedPanel = null;
        //ap = this.transform.parent.parent.parent.GetComponent<ShipAutopilot> ();
        //ship = this.transform.parent.parent.parent;
        DebugCursorConsole = GameObject.Find("DebugCursorConsole");

        DebugCursorConsole.GetComponent<Renderer>().enabled = true;
        mode = controlMode.sensor;

        targetOrientation = Vector3.zero;
        targetVelocity = Vector3.zero;
    }