Ejemplo n.º 1
0
 public void SetAbsoluteTarget(Vector3 absoluteTarget)
 {
     m_mode           = AimingMode.TARGET;
     m_aimTarget      = null;
     m_relativeTarget = absoluteTarget;
     Update();
 }
Ejemplo n.º 2
0
 public void SetTarget(MyEntity entity, Vector3? relativeTarget = null)
 {
     m_mode = AimingMode.TARGET;
     m_aimTarget = entity;
     m_relativeTarget = relativeTarget;
     Update();
 }
Ejemplo n.º 3
0
 public void SetTarget(MyEntity entity, Vector3?relativeTarget = null)
 {
     m_mode           = AimingMode.TARGET;
     m_aimTarget      = entity;
     m_relativeTarget = relativeTarget;
     Update();
 }
Ejemplo n.º 4
0
 public void SetAbsoluteTarget(Vector3 absoluteTarget)
 {
     m_mode = AimingMode.TARGET;
     m_aimTarget = null;
     m_relativeTarget = absoluteTarget;
     Update();
 }
Ejemplo n.º 5
0
    public List <Node> GetInRange(Node startPoint, int distance, AimingMode am)
    {
        List <Node> toReturn = new List <Node>();

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                if (GetDistance(startPoint, tiles[x, y]) <= distance)
                {
                    toReturn.Add(tiles[x, y]);
                }
            }
        }

        if (am == AimingMode.line)
        {
            for (int i = 0; i < toReturn.Count; i++)
            {
                if (toReturn[i].xPos != startPoint.xPos && toReturn[i].yPos != startPoint.yPos)
                {
                    toReturn.RemoveAt(i);
                    i--;
                }
            }
        }

        return(toReturn);
    }
Ejemplo n.º 6
0
 public void SetTarget(MyEntity entity, Vector3?relativeTarget = new Vector3?())
 {
     this.m_mode           = AimingMode.TARGET;
     this.m_aimTarget      = entity;
     this.m_relativeTarget = relativeTarget;
     this.Update();
 }
Ejemplo n.º 7
0
 public void SetAbsoluteTarget(Vector3 absoluteTarget)
 {
     this.m_mode           = AimingMode.TARGET;
     this.m_aimTarget      = null;
     this.m_relativeTarget = new Vector3?(absoluteTarget);
     this.Update();
 }
Ejemplo n.º 8
0
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            AimMode = AimingMode.Object;
            camRay = cam.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(camRay, out hit))
            {
                target = hit.transform;
                targetName = target.name;
            }
        }

        if (!target)
            AimMode = AimingMode.Mouse;

        switch (AimMode)
        {
            case AimingMode.Object:
                if (!target) break;
                targetPoint = target.position;
                break;
            case AimingMode.Mouse:
                if (!cam) break;
                camRay = cam.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(camRay, out hit))
                {
                    targetPoint = hit.point;
                }
                else
                    targetPoint = camRay.GetPoint(100000f);
                break;
            case AimingMode.Camera:
                if (!cam) break;
                if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit))
                    targetPoint = hit.point;
                else
                    targetPoint = cam.transform.forward * 10000f;
                break;
        }

        localTargetPoint = Hull.InverseTransformPoint(targetPoint);
        localTargetPoint.y = 0f;
        t = Quaternion.LookRotation(localTargetPoint);
        Turret_.localRotation = Quaternion.RotateTowards(Turret_.localRotation, t, ySpeed * Time.deltaTime);

        localTargetPoint = Turret_.InverseTransformPoint(targetPoint + (Hull.position - MainGun.position));
        localTargetPoint.x = 0f;

        if (localTargetPoint.z > 0f)
        {
            q = Quaternion.LookRotation(localTargetPoint);
            if (q.x <= AngleY / 180 && q.x >= -AngleY / 360)
                MainGun.localRotation = Quaternion.RotateTowards(MainGun.localRotation, q, xSpeed * Time.deltaTime);
        }
    }
Ejemplo n.º 9
0
 public void StopAiming()
 {
     m_aimTarget      = null;
     m_mode           = AimingMode.FIXATED;
     m_relativeTarget = null;
 }
Ejemplo n.º 10
0
 public void FollowMovement()
 {
     m_aimTarget      = null;
     m_mode           = AimingMode.FOLLOW_MOVEMENT;
     m_relativeTarget = null;
 }
Ejemplo n.º 11
0
 public MyBotAiming(MyBotNavigation parent)
 {
     m_parent       = parent;
     m_mode         = AimingMode.FOLLOW_MOVEMENT;
     m_rotationHint = Vector3.Zero;
 }
Ejemplo n.º 12
0
 public void StopAiming()
 {
     m_aimTarget = null;
     m_mode = AimingMode.FIXATED;
     m_relativeTarget = null;
 }
Ejemplo n.º 13
0
 public void FollowMovement()
 {
     m_aimTarget = null;
     m_mode = AimingMode.FOLLOW_MOVEMENT;
     m_relativeTarget = null;
 }
Ejemplo n.º 14
0
 public MyBotAiming(MyBotNavigation parent)
 {
     m_parent = parent;
     m_mode = AimingMode.FOLLOW_MOVEMENT;
     m_rotationHint = Vector3.Zero;
 }