예제 #1
0
    public bool MoveUnit()
    {
        //Cast a ray to find the object clicked on
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 100))
        {
            //store the hit game object's scr_Field
            scr_Field clickedField = hit.transform.gameObject.GetComponent <scr_Field>();
            if (clickedField.isPossible)
            {
                //Move unit and update current field if the clicked field was a valid field
                transform.position = hit.transform.position;
                currentField       = clickedField;
                remainingMovement--;
            }
        }

        //Stops the player from being active. Currently at the end of lap, but should be changed
        if (currentField.isLapFinish)
        {
            isStillPlaying = false;
        }

        return(true);
    }
예제 #2
0
 private void Crash()
 {
     remainingMovement  = 0;
     currentField       = startField;
     transform.position = startField.gameObject.transform.position;
     currentSection     = currentField.GetComponentInParent <scr_Section>();
 }
예제 #3
0
 public void Start()
 {
     gearObject         = GetComponent <scr_Gear>();
     currentField       = startField;
     speed              = 8;
     transform.position = startField.transform.position;
 }
예제 #4
0
    private List <scr_Field> PossibleFieldsChangeSection()
    {
        List <scr_Field> Fields  = new List <scr_Field>();
        scr_Section      nextSec = currentSection.nextSection;

        //Add the next field in middle lane
        scr_Field tempField = nextSec.lanes[currentField.lane].fields[0];

        if (LegitimateMove(tempField))
        {
            tempField.isPossible = true;
            Fields.Add(tempField);
        }

        //Add the next field in the lane to the right
        if (currentSection.rule == scr_Section.LaneShiftRules.both || currentSection.rule == scr_Section.LaneShiftRules.moveRight)
        {
            if (currentField.lane > 0)
            {
                tempField = nextSec.lanes[currentField.lane - 1].fields[0];
                if (LegitimateMove(tempField))
                {
                    tempField.isPossible = true;
                    Fields.Add(tempField);
                }
            }
        }

        //Add the next field in left lane
        if (currentSection.rule == scr_Section.LaneShiftRules.both || currentSection.rule == scr_Section.LaneShiftRules.moveLeft)
        {
            if (currentField.lane < currentSection.lanes.Count - 1)
            {
                tempField = nextSec.lanes[currentField.lane + 1].fields[0];
                if (LegitimateMove(tempField))
                {
                    tempField.isPossible = true;
                    Fields.Add(tempField);
                }
            }
        }

        currentSection        = nextSec;
        sectionStoppedCounter = 0;
        return(Fields);
    }
예제 #5
0
    List <scr_Field> PossibleFieldsSection()
    {
        List <scr_Field> Fields = new List <scr_Field>();

        //Add the next field in middle lane
        scr_Field tempField = currentSection.lanes[currentField.lane].fields[currentField.placementNumber + 1];

        if (LegitimateMove(tempField))
        {
            tempField.isPossible = true;
            Fields.Add(tempField);
        }

        //Add the next field in the lane to the right
        if (currentSection.rule == scr_Section.LaneShiftRules.both || currentSection.rule == scr_Section.LaneShiftRules.moveRight)
        {
            if (currentField.lane > 0)
            {
                tempField = currentSection.lanes[currentField.lane - 1].fields[currentField.placementNumber + 1];
                if (LegitimateMove(tempField))
                {
                    tempField.isPossible = true;
                    Fields.Add(tempField);
                }
            }
        }

        //Add the next field in left lane
        if (currentSection.rule == scr_Section.LaneShiftRules.both || currentSection.rule == scr_Section.LaneShiftRules.moveLeft)
        {
            if (currentField.lane < currentSection.lanes.Count - 1)
            {
                tempField = currentSection.lanes[currentField.lane + 1].fields[currentField.placementNumber + 1];
                if (LegitimateMove(tempField))
                {
                    tempField.isPossible = true;
                    Fields.Add(tempField);
                }
            }
        }

        return(Fields);
    }
예제 #6
0
 // checks if field is viable and legitimate i.e. no other racers, it exists etc.
 public bool LegitimateMove(scr_Field possibleMove)
 {
     return(true);
 }