Exemple #1
0
    private void PlayFootsteps(surfaces surface)
    {
        currentSource = sources.Dequeue();
        switch (surface)
        {
        case (surfaces.grass):
            for (int i = 0; i < allFootsteps.Length; i++)
            {
                if (allFootsteps[i].footstepSurface == surfaces.grass)
                {
                    currentSource.clip = allFootsteps[i].footstepAudioClips[Random.Range(0, allFootsteps[i].footstepAudioClips.Length)];
                }
            }
            break;

        case (surfaces.wood):
            for (int i = 0; i < allFootsteps.Length; i++)
            {
                if (allFootsteps[i].footstepSurface == surfaces.wood)
                {
                    currentSource.clip = allFootsteps[i].footstepAudioClips[Random.Range(0, allFootsteps[i].footstepAudioClips.Length)];
                }
            }
            break;
        }
        currentSource.Play();
        sources.Enqueue(currentSource);
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            PlayFootsteps(currentSurface);
            stopCoroutine = false;
            StartCoroutine(WalkCycle());
        }
        if (Input.GetKeyUp(KeyCode.W))
        {
            stopCoroutine = true;
        }

        if (Physics.Raycast(transform.position, Vector3.down, out hit))
        {
            switch (hit.collider.tag)
            {
            case ("Grass"):
                currentSurface = surfaces.grass;
                break;

            case ("Wood"):
                currentSurface = surfaces.wood;
                break;
            }
        }
    }
        PlansConfiguration ConvertPlans(surfaces innerPlans)
        {
            var plansConfiguration = new PlansConfiguration();

            if ((innerPlans != null) && (innerPlans.surface != null))
            {
                foreach (var innerPlan in innerPlans.surface)
                {
                    var plan = new Plan()
                    {
                        Caption = innerPlan.caption,
                        Height = Double.Parse(innerPlan.height) * 10,
                        Width = Double.Parse(innerPlan.width) * 10
                    };

                    foreach (var innerLayer in innerPlan.layer)
                    {
                        if (innerLayer.elements == null)
                            continue;

                        switch (innerLayer.name)
                        {
                            case "План":
                                foreach (var innerElement in innerLayer.elements)
                                {
                                    switch (innerElement.@class)
                                    {
                                        case "TSCDePicture":
                                            int pictureIndex = 0;
                                            AddPictire(plan, innerElement, ref pictureIndex);
                                            break;

                                        case "TSCDeRectangle":
                                            AddRectangle(plan, innerElement);
                                            break;

                                        case "TSCDeEllipse":
                                            AddEllipse(plan, innerElement);
                                            break;

                                        case "TSCDeLabel":
                                            AddLabel(plan, innerElement);
                                            break;

                                        case "TSCDeText":
                                            AddLabel(plan, innerElement, true);
                                            break;

                                        case "TSCDePolyLine":
                                            AddPolyLine(plan, innerElement);
                                            break;

                                        case "TSCDePolygon":
                                            AddPolygon(plan, innerElement);
                                            break;

                                        default:
                                            Logger.Error("ConfigurationConverter.ConvertPlans: Неизвестный элемент " + innerElement.@class);
                                            break;
                                    }
                                }
                                break;
                            case "Несвязанные зоны":
                            case "Пожарные зоны":
                            case "Охранные зоны":
                            case "Зоны":
                                foreach (var innerElement in innerLayer.elements)
                                {
                                    int? zoneNo = null;

                                    long longId = long.Parse(innerElement.id);
                                    int intId = (int)longId;
                                    foreach (var zone in DeviceConfiguration.Zones)
                                    {
                                        foreach (var zoneShapeId in zone.ShapeIds)
                                        {
                                            if ((zoneShapeId == longId.ToString()) || (zoneShapeId == intId.ToString()))
                                            {
                                                zoneNo = zone.No;
                                            }
                                        }
                                    }

                                    switch (innerElement.@class)
                                    {
                                        case "TFS_PolyZoneShape":
                                            AddPolygonZone(plan, innerElement, zoneNo);
                                            break;

                                        case "TFS_ZoneShape":
                                            AddRectangleZone(plan, innerElement, zoneNo);
                                            break;

                                        case "TSCDeRectangle":
                                            AddRectangle(plan, innerElement);
                                            break;

                                        case "TSCDeEllipse":
                                            AddEllipse(plan, innerElement);
                                            break;

                                        case "TSCDeLabel":
                                            AddLabel(plan, innerElement);
                                            break;

                                        case "TSCDeText":
                                            AddLabel(plan, innerElement, true);
                                            break;

                                        case "TSCDePolyLine":
                                            AddPolyLine(plan, innerElement);
                                            break;

                                        case "TSCDePolygon":
                                            AddPolygon(plan, innerElement);
                                            break;

                                        default:
                                            Logger.Error("ConfigurationConverter.ConvertPlans: Неизвестный элемент " + innerElement.@class);
                                            break;
                                    }
                                }
                                break;

                            case "Устройства":
                                foreach (var innerElement in innerLayer.elements)
                                {
                                    AddDevice(plan, innerElement);
                                }
                                break;
                        }
                    }
                    plansConfiguration.Plans.Add(plan);
                }
            }

            DeleteDirectory(Environment.CurrentDirectory + "\\Pictures");
            return plansConfiguration;
        }