Пример #1
0
 /// <summary>
 /// Reset the variables used for editing a line
 /// </summary>
 public void ResetEditingInfo()
 {
     editingLine         = null;
     editingLineStations = new List <StationController>();
     travelTimes         = new List <float>();
     editLineName        = "new line name";
 }
Пример #2
0
    void ScrollBlocks(BLOCK nextBlock)
    {
        currentBlockType = Block.BlockFactory(nextBlock);
        GetComponent <SpriteRenderer>().sprite = currentBlockType.blockSprite;

        LineController lineC = GetComponent <LineController>();

        if (lineC.currentLine != null)
        {
            lineC.currentLine.ResetPath();
        }

        foreach (GameObject go in couplers)
        {
            LineCoupler lc = go.GetComponent <LineCoupler>();

            if (lc.currentLine != null)
            {
                lc.currentLine.ResetPath();
            }
        }

        SetValue(0);

        // Custom collider size depending on block type
        if (currentBlockType.blockType == BLOCK.EMPTY)
        {
            GetComponent <BoxCollider2D>().size = new Vector2(2.0f, 2.0f);
        }
        else
        {
            GetComponent <BoxCollider2D>().size = new Vector2(1.0f, 1.0f);
        }
    }
Пример #3
0
    public void ClearAllLine()
    {
        foreach (var l in selfLineList)
        {
            if (l != null)
            {
                Destroy(l.gameObject);
            }
        }

        selfLineList.Clear();

        // foreach(var l in remoteLineCtrlList)
        // {
        //     if (l != null)
        //         Destroy(l.gameObject);
        // }

        // remoteLineCtrlList.Clear();

        if (creatingLine != null)
        {
            Destroy(creatingLine.gameObject);
            creatingLine = null;
        }

        if (selectedLine != null)
        {
            Destroy(selectedLine.gameObject);
            selectedLine = null;
        }

        _lineLeft = lineLeftMax;
        fieldMenu.UpdateLineLeftAmount(_lineLeft);
    }
Пример #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int currentMonth = DateTime.Now.Month;

            int[] monthArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            cbMonth.ItemsSource  = monthArray;
            cbMonth.SelectedItem = currentMonth;
            int currentYear = DateTime.Now.Year;

            int[] yearArray = { currentYear - 1, currentYear, currentYear + 1 };
            cbYear.ItemsSource  = yearArray;
            cbYear.SelectedItem = currentYear;

            lineList            = LineController.Select();
            cbLine.ItemsSource  = lineList.Where(w => w.SectionId == "F").Select(s => s.LineId).ToList();
            cbLine.SelectedItem = lineList.Where(w => w.SectionId == "F").Select(s => s.LineId).FirstOrDefault();

            string lineId = "";

            lineId = cbLine.SelectedValue as string;

            int _month = 0, _year = 0;

            Int32.TryParse(cbMonth.SelectedValue.ToString(), out _month);
            Int32.TryParse(cbYear.SelectedValue.ToString(), out _year);
            requestList            = CieControlIncentiveController.Select(lineId, _month, _year);
            dgvRequest.ItemsSource = requestList;
        }
Пример #5
0
    public void Init()
    {
        line = transform.GetChild(0).GetComponent <LineController>();

        objectSpawner = ObjectSpawner.Instance;

        if (currentBase != null)
        {
            currentBase.player = this;
        }


        defaultScale = transform.localScale.x;

        targetLocation = transform.localPosition;

        cameraController = Camera.main.GetComponent <CameraController>();

        renderer = transform.GetChild(2).GetComponent <SpriteRenderer>();

        gameplayController = GameplayController.Instance;

        trailRenderer = GetComponent <TrailRenderer>();

        SetCurrentBase();

        skinSprite = skin.GetComponent <SpriteRenderer>();


        skinSprite.sprite = tether_sprites[GameplayController.LevelIndex];


        isInit = true;
    }
Пример #6
0
    void FindVisibleTargets()
    {
        visibleTargets.Clear();
        Collider[]     targetsInViewRadius = Physics.OverlapSphere(transform.position, _viewRadius, _targetMask);
        List <Vector3> tentaclePositions   = LineController.GetPositions();

        if (tentaclePositions != null && targetsInViewRadius != null)
        {
            for (int i = 0; i < tentaclePositions.Count - 1; i++)
            {
                Vector3 target      = tentaclePositions[i];           //targetsInViewRadius[i].transform;
                Vector3 dirToTarget = (target - transform.position).normalized;
                if (Vector3.Angle(transform.forward, dirToTarget) < _viewAngle / 2)
                {
                    float dstToTarget = Vector3.Distance(transform.position, target);
                    if (Physics.Raycast(transform.position, dirToTarget, _viewRadius, _targetMask))
                    {
                        //targetsInViewRadius[i].gameObject.GetComponent<TentacleController>().TentacleMoveBack(this.gameObject);
                        Debug.Log("COLLISION");
                        currentHuman.SetState(HumanState.RunningOut);
                        //visibleTargets.Add(target);
                    }
                }
            }
        }
    }
    private void MirrorNumberOfLineEffectsWithAreaFinder()
    {
        int CharacterCount = AreaFinder.GetCharacterCount();

        if (CharacterCount > LineEffects.Count)
        {
            int difference = CharacterCount - LineEffects.Count;
            for (int i = 0; i < difference; i++)
            {
                GameObject newLineEffect = Instantiate(LineEffectPrefab, transform);
                newLineEffect.transform.position = transform.position;

                LineController newLineController = newLineEffect.GetComponent <LineController>();
                LineEffects.Add(newLineController);
            }
        }
        else
        {
            int difference = LineEffects.Count - CharacterCount;
            for (int i = 0; i < difference; i++)
            {
                Destroy(LineEffects[i].gameObject);
                LineEffects.RemoveAt(i);
                i--;
                difference--;
            }
        }
    }
Пример #8
0
    public void Init()
    {
        player = PlayerController.Instance;

        lineController = LineController.Instance;

        levelController = LevelController.Instance;

        audioController = AudioController.Instance;

        obj_bases = GameObject.FindWithTag("Objects/bases").transform;

        InstantiateBaseObject(3, Vector2.up * 10);

        PositionBases();

        player.Init();

        lineController.Init();

        if (audioController != null)
        {
            audioController.Init();
        }

        isInit = true;
    }
Пример #9
0
    public void EnsureTrail()
    {
        if (drawing)
        {
            lastUpdate += Time.deltaTime;
            if (lastUpdate > pointInterval)
            {
                lastUpdate -= pointInterval;
                curLine.AddPoint(transform.position);
                Vector3 newPos = transform.localPosition;
                newPos = new Vector3(newPos.x / canvasDims.x, newPos.y / canvasDims.y + 20, transform.position.z);
                curLine2.AddPoint(newPos);
            }
            return;
        }
        drawing = true;
        var line  = Instantiate(linePrefab, canvas.transform.parent);
        var line2 = Instantiate(linePrefab, digitCanvas.transform);

        lineList.Add(line);
        lineList.Add(line2);
        curLine = line.GetComponent <LineController>();
        curLine.SetReal();
        curLine2 = line2.GetComponent <LineController>();
        curLine2.SetFake();
        curLine.AddPoint(transform.position);
        Vector3 p2 = transform.localPosition;

        p2 = new Vector3(p2.x / canvasDims.x, p2.y / canvasDims.y + 20, transform.position.z);
        curLine2.AddPoint(p2);
    }
    private void createRays()
    {
        //makes all the rays and then adds them to the list

        Transform child = this.transform.Find("Starting Point");

        if (child == null)
        {
            child = new GameObject("Starting Point").transform;

            child.SetParent(this.transform);
            child.localPosition = new Vector3(0, .55f, 0);
            child.rotation      = this.transform.rotation;
        }

        List <List <Vector2> > allLines = this.getPoints(child.position, child.up);

        GameObject rayPrefab = (GameObject)SceneResouces.SceneObjects["Default"][typeof(GameObject)]["Ray"];

        foreach (List <Vector2> lines in allLines)
        {
            GameObject rayGO = Instantiate(rayPrefab);
            rayGO.transform.SetParent(this.transform);
            rayGO.transform.position = Vector3.zero;
            LineController lc = rayGO.GetComponent <LineController>();
            lc.setPoints(VertexExtension.toVector3Array(lines.ToArray()));
            this.lineControllers.Add(lc);
        }
    }
    void UpdateLineObj(LineController line, Vector3 start, Vector3 end)
    {
        var lineObj    = line.gameObject;
        var lenghtLeft = LineLenghtLeft;
        var diff       = (end - start);
        var dir        = diff.normalized;

        if (diff.magnitude > lenghtLeft)
        {
            end = start + dir * lenghtLeft;
        }

        diff = (end - start);
        if (diff.magnitude > max_line_length)
        {
            end = start + dir * max_line_length;
        }

        diff = (end - start);
        // 残りの分量をリアルタイムに反映
        lenghtLeft = Mathf.Max(lenghtLeft - diff.magnitude, 0);

        if (onUpdateLineLengthLeft != null)
        {
            onUpdateLineLengthLeft(lenghtLeft / max_line_length_total);
        }

        lineObj.transform.position   = (start + end) / 2;
        lineObj.transform.right      = (end - start).normalized;
        lineObj.transform.localScale = new Vector3((end - start).magnitude, lineWidth, lineDepth);
        line.UpdateStartEnd(start, end);
    }
 void Start()
 {
     Debug.Log("State starts as: " + currentState);
     lineController = LineController.Shared;
     setBackgroundImage("Assets/test.jpg");
     currentState = State.None;
 }
Пример #13
0
// Use this for initialization
    void Start()
    {
        lineController     = GetComponent <LineController>();
        functionController = GetComponent <FunctionController>();

        pController = GetComponent <PlayerController>();
    }
Пример #14
0
    private void SpawnCars()
    {
        for (int i = 0; i < aiCarCount; i++)
        {
            GameObject aiCarParent = new GameObject("AICar" + i);
            aiCarParent.transform.parent = transform;

            GameObject car = Instantiate(AICar, spawningPoints.GetSpawnPoint(), Quaternion.identity);
            car.transform.parent = aiCarParent.transform;

            GameObject ball = Instantiate(AICarBall);
            car.GetComponent <CarAIController>().Ball       = ball.transform;
            ball.GetComponent <BallMovement>().ballPosition = car.transform.Find("BallPosition");
            ball.transform.position = ball.GetComponent <BallMovement>().ballPosition.position;
            ball.GetComponent <BallCollider>().IsThisAIBall = true;
            ball.transform.parent = aiCarParent.transform;

            // positioning canvas does not work in editor, works in build
            GameObject canvas = Instantiate(AICarCanvas, new Vector3(car.transform.position.x, car.transform.position.y + 2, car.transform.position.z), Quaternion.Euler(45, -90, 0));
            canvas.GetComponent <CarUIController>().isThisCanvasAI = true;
            FollowTarget followTarget = canvas.GetComponent <FollowTarget>();
            followTarget.Target  = car.transform;
            followTarget.enabled = true;
            canvas.transform.SetParent(aiCarParent.transform);

            GameObject     line           = Instantiate(AILine, car.transform.position, Quaternion.identity);
            LineController lineController = line.GetComponent <LineController>();
            lineController.Car    = car.transform;
            lineController.Ball   = ball.transform;
            line.transform.parent = aiCarParent.transform;

            car.GetComponent <CarAIController>().AICarNumber = i;
        }
    }
Пример #15
0
 /// <summary>
 /// Called by RoutingModel to set up queues for different lines that go through the station.
 /// Even Walking and Bike lines are included
 /// </summary>
 public void InitLineQueues()
 {
     if (lineThruThisStation == null)
     {
         Debug.LogError("lineThruThisStation == null");
         return;
     }
     lineQueues = new Dictionary <string, Queue <TravelerController> >();
     foreach (var line in lineThruThisStation)
     {
         string keyString = LineController.MakeKeyString(line.id, LineDirection.OutBound);
         if (!lineQueues.ContainsKey(keyString))
         {
             lineQueues.Add(keyString, new Queue <TravelerController>()); //Queue for outbound.
         }
         keyString = LineController.MakeKeyString(line.id, LineDirection.InBound);
         if (!lineQueues.ContainsKey(keyString))
         {
             lineQueues.Add(keyString, new Queue <TravelerController>()); //Queue for inbound.
         }
     }
     foreach (var queue in lineQueues)
     {
         queueStats.Add(new QueueStats
         {
             name    = queue.Key,
             queuing = 0
         });
     }
 }
Пример #16
0
    static void SaveStationsAndLines()
    {
        var sgos = GameObject.FindGameObjectsWithTag("TransStation");

        if (sgos.Length < 1)
        {
            Debug.Log("no stations to save.");
            return;
        }
        var lgos = GameObject.FindGameObjectsWithTag("TransLine");

        if (lgos.Length < 1)
        {
            Debug.Log("no lines to save.");
            return;
        }

        var path = EditorUtility.SaveFilePanel("Save XML Data", "Assets/Transportations", "", "xml");

        if (path.Length == 0)
        {
            EditorUtility.DisplayDialog("Saving Cancelled", "No file was provided", "OK");
            return;
        }

        List <BaseStation> stations = new List <BaseStation>();

        foreach (var go in sgos)
        {
            var sc = go.GetComponent <StationController>();
            var bs = new BaseStation
            {
                id   = int.Parse(sc.name),
                x    = go.transform.position.x,
                y    = go.transform.position.y,
                z    = go.transform.position.z,
                name = sc.stationName,
            };
            stations.Add(bs);
        }

        List <BaseLine> lines = new List <BaseLine>();

        foreach (var go in lgos)
        {
            var lc = go.GetComponent <LineController>();
            var bl = LineController.CreateBaseLine(lc);
            lines.Add(bl);
        }

        var container = new TrafficContainer();

        container.stations = stations;
        container.lines    = lines;
        container.Save(path);
        string stationStats = string.Format("{0} stations saved.", container.stations.Count);
        string lineStats    = string.Format("{0} lines saved.", container.lines.Count);

        EditorUtility.DisplayDialog("Saving Finished", stationStats + "\n" + lineStats + "\n to: " + path, "OK");
    }
Пример #17
0
 private void Awake()
 {
     posZ = (int)transform.position.z;
     Init();
     _pathfinding    = new Pathfinding(levelTiles);
     _lineController = new LineController();
 }
Пример #18
0
 // Start is called before the first frame update
 void Start()
 {
     lineController     = Listener.GetComponent <LineController>();
     listenerSineScript = Listener.GetComponent <SineWaveScript>();
     startTime          = Time.time;
     Speaker.GetComponent <Renderer>().enabled  = false;
     Listener.GetComponent <Renderer>().enabled = false;
 }
Пример #19
0
 void Start()
 {
     initialPosition = transform.position;
     boxCollider     = GetComponent <BoxCollider>();
     cube            = GetComponent <CubeController>();
     line            = GetComponent <LineController>();
     rb = GetComponent <Rigidbody>();
 }
Пример #20
0
    private void spawnLine(List <Vector2> drawingPoints)
    {
        Vector2        spawnPos = calcSpawnPos(drawingPoints);
        GameObject     temp     = Instantiate(lineObject, spawnPos, Quaternion.identity, this.transform);
        LineController drawable = temp.GetComponent <LineController>();

        drawable.setUp(drawingPoints, width);
    }
Пример #21
0
    void Awake()
    {
        s = this;
        Transform launchPointTrans = transform.Find("LaunchPoint");

        line         = GetComponent <LineRenderer>();
        line.enabled = false;
        points       = new List <Vector3>();
    }
Пример #22
0
        private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime today = DateTime.Now;

            lineList        = LineController.Select(section.SectionId);
            personalList    = PersonalController.Select(section.Keyword);
            workerLoginList = WorkerLoginController.SelectByLine(section.SectionId, today);
            lineAllList     = LineController.Select();
        }
    public static LineController createInstance(string name, LineMeshTypeInt lineMeshType, Transform parentTransform)
    {
        GameObject go = new GameObject(name);

        go.transform.parent = parentTransform;
        LineController lc = go.AddComponent <LineController> ();

        lc.initialize(lineMeshType, PropertiesSingleton.getLineRendererMaterial());
        return(lc);
    }
Пример #24
0
 public void EnsureNotTrail()
 {
     if (!drawing)
     {
         return;
     }
     drawing  = false;
     curLine  = null;
     curLine2 = null;
 }
Пример #25
0
    private void Start()
    {
        if (IsActive)
        {
            ShowLineRenderer();
            SetCollider();
        }

        _playerController = FindObjectOfType <PlayerController>();
        _lineController   = GetComponentInParent <LineController>();
    }
Пример #26
0
 // Use this for initialization
 void Start()
 {
     refObj                = GameObject.Find("LineObject");
     refLineObj            = GameObject.Find("LineController");
     agent                 = GetComponent <NavMeshAgent>();
     playerToPointDistance = 10;
     targetLinePointCount  = 0;
     t1 = refObj.GetComponent <LineObject>();
     g1 = refLineObj.GetComponent <LineController>();
     rigidbodyCylinder = GetComponent <Rigidbody>();
 }
Пример #27
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         DestroyImmediate(gameObject);
     }
 }
Пример #28
0
    bool CheckGridForLegalBlock(GameObject gridObj)
    {
        if (gridObj == null)
        {
            return(false);
        }
        LineController lineC = gridObj.GetComponent <LineController>();
        GridBehaviour  gridB = gridObj.GetComponent <GridBehaviour>();

        return(lineC.currentLine == null && gridB.currentBlockType.blockType == BLOCK.EMPTY);
    }
Пример #29
0
    public void C2A_UpdateLine(int sendFrom, LineController line, bool isCreate)
    {
        var Item  = ProtocolMaker.Mk_C2A_UpdateLine(sendFrom, line.lineId, line.transform.position, line.transform.eulerAngles, line.transform.localScale, isCreate);
        var json  = ProtocolMaker.SerializeToJson(Item);
        var bytes = StrToByteArray(json);

        if (stream.CanWrite)
        {
            ClientBaseDebugLog("writed C2A_UpdateLine");
            stream.Write(bytes, 0, bytes.Length);
        }
    }
Пример #30
0
    private void GenerateTravelInfoForRoute(Itinerary itinerary)
    {
        List <StationController> stops = itinerary.WayPoints;

        List <StageInfo> stageInfos = new List <StageInfo>();

        for (int i = 1; i < stops.Count; i++)
        {
            StationController first  = stops[i - 1];
            StationController second = stops[i];
            int lineId = StationController.GetCommonLineId(first, second);

            if (lineId < 0)
            {
                Debug.LogErrorFormat("no common line between {0}, {1}", first, second);
            }

            LineController line = Lines[lineId];
            string         key  = MakeKeyString(first, second);
            StageInfo      stageInfo;
            if (!StageInfos.TryGetValue(key, out stageInfo))
            {
                stageInfo            = new StageInfo();
                stageInfo.Start      = first;
                stageInfo.End        = second;
                stageInfo.Line       = line;
                stageInfo.TravelTime = line.GetLegTravelTime(first, second);
                stageInfo.Direction  = line.GetDirection(first, second);

                StageInfos.Add(key, stageInfo);
            }
            stageInfos.Add(stageInfo);
        }

        itinerary.StageInfos = stageInfos;

        List <StationController> transits = new List <StationController>();

        for (int i = 1; i < stops.Count - 1; i++)
        {
            StationController current = stops[i];

            int firstLineId  = stageInfos[i - 1].Line.id;
            int secondLineId = stageInfos[i].Line.id;
            if (firstLineId != secondLineId)
            {
                transits.Add(current);
            }
        }
        transits.Add(stops.Last());
        itinerary.Transits = transits;
    }
Пример #31
0
 void Start()
 {
     sequencer = GetComponent<Sequencer>();
     sequencer.tempo = tempo;
     sequencer.OnNextBar += OnNextBar;
     cameraController = GetComponent<CameraController>();
     monster =
       GameObject.Instantiate(monsterPrefab).GetComponent<MonsterController>();
     monster.speechGui = monsterSpeechGui;
     monster.SetLeftEnd(cameraController.ScreenLeft);
     monster.speakSpeed = 8.0f / tempo;
     line = GameObject.Instantiate(groundPrefab).GetComponent<LineController>();
     line.SetStartPoint(monster.GetRightEnd());
     line.SetLength(0.5f * cameraController.ScreenSize - monster.GetRightEnd());
 }