void Start()
    {
        area = GameObject.FindObjectOfType <MoveArea>();

        carveNavmesh.SetActive(false);
        scoreText.gameObject.SetActive(false);
    }
예제 #2
0
    public bool[] m_moveAriaActive;         // 移動範囲の表示判定

    // Use this for initialization
    void Start()
    {
        // 地面の高さを取得
        float pos_y = transform.position.y * 2;

        height = Mathf.RoundToInt(pos_y);
        // マスの位置を取得
        position[0] = (int)transform.position.x + 1;
        position[1] = (int)transform.position.z + 1;

        //追加部分
        m_displayArea    = new bool[(int)MoveAreaType.number];
        m_moveArea       = new GameObject[(int)MoveAreaType.number];
        m_color          = new Color[(int)MoveAreaType.number];
        m_moveAriaActive = new bool[(int)MoveAreaType.number];
        for (MoveAreaType i = 0; i < MoveAreaType.number; i++)
        {
            m_moveArea[(int)i] = Instantiate(Resources.Load(MoveArea.MoveAreaAssetsName(i)), transform.position, transform.rotation) as GameObject;
            m_moveArea[(int)i].transform.position = new Vector3
                                                    (
                m_moveArea[(int)i].transform.position.x + 0.5f,
                m_moveArea[(int)i].transform.position.y,
                m_moveArea[(int)i].transform.position.z + 0.5f
                                                    );
            m_moveArea[(int)i].name             = MoveArea.RemoveNameClone(m_moveArea[(int)i].name);
            m_moveArea[(int)i].transform.parent = gameObject.transform;
            m_color[(int)i] = m_moveArea[(int)i].GetComponent <Renderer>().material.color;
            m_moveArea[(int)i].SetActive(false);
        }
    }
예제 #3
0
    /// <summary>
    /// Действие с вышкой воинов
    /// </summary>
    /// <param name="warTower">Вышка воинов</param>
    void ActionWithWarTower(WarTower warTower)
    {
        MoveArea moveArea = warTower.moveArea;

        for (int i = 0; i < hits3D.Length; i++)
        {
            RaycastHit hit          = hits3D[i];
            Transform  hitTransform = hit.transform;
            if (hitTransform == null)
            {
                continue;
            }

            MoveArea hitMoveArea = hitTransform.GetComponent <MoveArea>();
            if (hitMoveArea == null)
            {
                continue;
            }

            if (hitMoveArea == moveArea)
            {
                Vector3 point = hit.point;
                warTower.SetPlacePoint(point);
                break;
            }
        }
        levelManager.SelectedObject = null;
    }
예제 #4
0
        private void BuildMovementService(MoveArea moveArea)
        {
            var shape = ShapeFactory <int> .Create(moveArea.Shape);

            var validHeight   = int.TryParse(moveArea.Dimension.Height, out int height);
            var validWidth    = int.TryParse(moveArea.Dimension.Width, out int width);
            var validMoveStep = int.TryParse(moveArea.MoveStep, out int moveStep);

            if (!validHeight || !validWidth || !validMoveStep || height == 0 || width == 0 || moveStep == 0)
            {
                throw new ArgumentException("Invalid dimension for the move area");
            }

            shape.Height = height;
            shape.Width  = width;


            _service = new MovementService <int, int>
                       (
                new Robo <int, int>(shape)
            {
                Step = moveStep
            }
                       );
        }
예제 #5
0
        public MainApp(ILogger <MainApp> logger, IOptions <MoveArea> moveArea, IOptions <RoboCommandSource> roboCommandSource)
        {
            _logger            = logger;
            _roboCommandSource = roboCommandSource.Value;
            _moveArea          = moveArea.Value;

            System.Console.OutputEncoding = Encoding.ASCII;
        }
    void Start()
    {
        m_OriginalPos = this.transform.position;
        moveArea      = FindObjectOfType <MoveArea>();
        BoxCollider2D BCollider = this.gameObject.AddComponent <BoxCollider2D>();

        BCollider.isTrigger = true;
    }
예제 #7
0
파일: GuardAI.cs 프로젝트: cyv-cg/FE
    Cell[] FindPath()
    {
        Cell[] tilesWhereUnitCanAttackFrom = Map.GetExtendedArea(new Cell[1] {
            Map.UnitTile(Target)
        }, AtkData);
        List <Cell> attackArea = new List <Cell>();

        foreach (Cell c in tilesWhereUnitCanAttackFrom)
        {
            attackArea.Add(c);
        }

        Cell[] tilesWhereTargetCanCounterFrom = Map.GetExtendedArea(new Cell[1] {
            Map.UnitTile(Target)
        }, Target.Unit.inventory.GetAttackData(Target));
        List <Cell> counterArea = new List <Cell>();

        foreach (Cell c in tilesWhereTargetCanCounterFrom)
        {
            counterArea.Add(c);
        }

        List <Cell> preferenceArea = new List <Cell>();

        foreach (Cell c in attackArea)
        {
            if (!counterArea.Contains(c))
            {
                preferenceArea.Add(c);
            }
        }

        List <Cell> area = preferenceArea.Count == 0 ? attackArea : preferenceArea;

        Cell targetTile = area[UnityEngine.Random.Range(0, tilesWhereUnitCanAttackFrom.Length)];

        foreach (Cell c in tilesWhereUnitCanAttackFrom)
        {
            if (c == Map.UnitTile(Fighter))
            {
                targetTile = Map.UnitTile(Fighter);
            }
        }

        List <Cell> range = new List <Cell>();

        Cell[] path = QPath.FindPath(Fighter, Map.UnitTile(Fighter), targetTile, Cell.EstimateDistance);

        foreach (Cell c in path)
        {
            if (MoveArea.Contains(c) && area.Contains(c))
            {
                range.Add(c);
            }
        }

        return(range.ToArray());
    }
예제 #8
0
파일: MoveArea.cs 프로젝트: kyn320/Breaker
 private void OnTriggerEnter2D(Collider2D _col)
 {
     if (_col.CompareTag("MoveArea"))
     {
         MoveArea attachArea      = _col.GetComponent <MoveArea>();
         int      compositeAreaID = Mathf.Min(areaID, attachArea.areaID);
         compositeList.Add(attachArea);
         areaID = compositeAreaID;
         UpdateAiAreaID();
     }
 }
 void Start()
 {
     moveArea = FindObjectOfType <MoveArea>();
     if (GetComponent <BoxCollider2D>() == null)
     {
         BoxCollider2D BCollider = this.gameObject.AddComponent <BoxCollider2D>();
         BCollider.isTrigger = true;
         Vector2 OriColliderSize = BCollider.size;
         BCollider.size = OriColliderSize * 0.9f;
     }
 }
예제 #10
0
        private void Handle(WorldClient client, GMCreateMobPacket packet)
        {
            for (int i = 0; i < packet.NumberOfMobs; i++)
            {
                // TODO: calculate move area.
                var moveArea = new MoveArea(_movementManager.PosX > 10 ? _movementManager.PosX - 10 : 1, _movementManager.PosX + 10, _movementManager.PosY > 10 ? _movementManager.PosY - 10 : _movementManager.PosY, _movementManager.PosY + 10, _movementManager.PosZ > 10 ? _movementManager.PosZ - 10 : 1, _movementManager.PosZ + 10);

                var mob = _mobFactory.CreateMob(packet.MobId, false, moveArea);

                _mapProvider.Map.AddMob(mob);
            }
        }
예제 #11
0
    void Start()
    {
        m_OriginalPos = this.transform.position;
        moveArea      = FindObjectOfType <MoveArea>();
        BoxCollider2D BCollider = this.gameObject.AddComponent <BoxCollider2D>();

        BCollider.isTrigger = true;
        Vector2 OriColliderSize = BCollider.size;

        BCollider.size       = OriColliderSize * 0.8f;
        mTempColliderObjList = new List <GameObject>();
    }
예제 #12
0
파일: BaseAI.cs 프로젝트: cyv-cg/FE
    void GetStfData()
    {
        StfData = Fighter.Unit.inventory.GetStaffData(Fighter);

        if (StfData != null)
        {
            foreach (Cell c in Map.GetExtendedArea(MoveArea.ToArray(), StfData))
            {
                StaffArea.Add(c);
            }
        }
    }
예제 #13
0
파일: BaseAI.cs 프로젝트: cyv-cg/FE
    void GetAtkData()
    {
        AtkData = Fighter.Unit.inventory.GetAttackData(Fighter);

        if (AtkData != null)
        {
            foreach (Cell c in Map.GetExtendedArea(MoveArea.ToArray(), AtkData))
            {
                AttackArea.Add(c);
            }
        }
    }
예제 #14
0
    void Start()
    {
        m_OriginalPos = this.transform.position;
        moveArea      = FindObjectOfType <MoveArea>();
        BoxCollider2D BCollider = this.gameObject.AddComponent <BoxCollider2D>();

        BCollider.isTrigger = true;
        Vector2 OriColliderSize = BCollider.size;

        BCollider.size = OriColliderSize * 0.9f;

        //抓場景所有的移動物件
        moveObjs = GameObject.FindGameObjectsWithTag("moveItem");
    }
예제 #15
0
 //移動
 public void Move()
 {
     if (!m_move)
     {
         return;
     }
     MoveLenge();
     if (m_moveRoute.Length != m_routeCount)
     {
         return;
     }
     m_move       = false;
     m_moveRoute  = null;
     m_routeCount = 0;
     MoveArea.ResetMoveArea();
 }
        private void HandleGMCreateMob(GMCreateMobPacket gmCreateMobPacket)
        {
            if (!_databasePreloader.Mobs.ContainsKey(gmCreateMobPacket.MobId))
            {
                _packetsHelper.SendGmCommandError(Client, PacketType.GM_CREATE_MOB);
                return;
            }

            for (int i = 0; i < gmCreateMobPacket.NumberOfMobs; i++)
            {
                // TODO: calculate move area.
                var moveArea = new MoveArea(PosX > 10 ? PosX - 10 : 1, PosX + 10, PosY > 10 ? PosY - 10 : PosY, PosY + 10, PosZ > 10 ? PosZ - 10 : 1, PosZ + 10);

                var mob = _mobFactory.CreateMob(gmCreateMobPacket.MobId, false, moveArea, Map);

                Map.AddMob(mob);
            }

            _packetsHelper.SendGmCommandSuccess(Client);
        }
예제 #17
0
    void Start()
    {
        PlayerController controller = GameObject.FindObjectOfType <PlayerController>();

        if (controller != null)
        {
            player = controller.gameObject.transform;
        }

        area    = GameObject.FindObjectOfType <MoveArea>();
        manager = GameObject.FindObjectOfType <GameManager>();

        rend = GetComponentInChildren <Renderer>();
        rend.material.color = normalColor;

        path = new NavMeshPath();

        agent.speed   = walkspeed;
        agent.enabled = false;

        Instantiate(spawnEffect, transform.position, transform.rotation);
        transform.Translate(Vector3.up * spawnHeight);
    }
예제 #18
0
            static bool Prefix(FishingSystem_t __instance, FishInfo ___fishInfo, Transform ___shoal, IFishingMan ___fishingMan, ref MoveArea ___area, FishingInfo ___fishingAreaInfo, float ___fishSpeedBaseFactor, float ___fishDashBaseFactor, float ___fishWaitBaseFactor, FishingUI_t ___hud)
            {
                if (!enabled)
                {
                    if (origBaitID != -1)
                    {
                        OtherConfig.Self.BaitID = origBaitID;
                    }
                    return(true);
                }
                Dbgl("Wait for fish");

                if (OtherConfig.Self.BaitID != -1)
                {
                    origBaitID = OtherConfig.Self.BaitID;
                    OtherConfig.Self.BaitID = -1;
                }

                Fish_t fish = null;

                if (string.IsNullOrEmpty(___fishInfo.fishPrefabPath))
                {
                    UnityEngine.Debug.LogError("fishPrefabPath = is null!");
                }
                else
                {
                    GameObject original = Singleton <ResMgr> .Instance.LoadSync <GameObject>(___fishInfo.fishPrefabPath, false, false);

                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(original, ___fishInfo.FishBornTrans.position, Quaternion.identity);
                    gameObject.transform.parent     = ___shoal;
                    gameObject.transform.localScale = Vector3.one;
                    gameObject.SetActive(true);
                    fish = gameObject.GetComponent <Fish_t>();
                }
                if (fish != null)
                {
                    Vector3 vector = ___fishInfo.FishBornTrans.position - ___fishingMan.Pos;
                    ___area               = new MoveArea();
                    ___area.angle         = ___fishingAreaInfo.angleLimit / 2f;
                    ___area.dir           = vector.normalized;
                    ___area.fishingManPos = ___fishingMan.Pos;
                    ___fishInfo.GenPowerFactor(fish.PowerValue);
                    ___fishInfo.GenSpeedFactor(fish.SpeedValue, ___fishSpeedBaseFactor);
                    ___fishInfo.GenAngerFactor(fish.AngerValue, ___fishDashBaseFactor);
                    ___fishInfo.GenTenacityFactor(fish.TenacityValue);
                    ___fishInfo.SetBaseWaitTime(___fishWaitBaseFactor);
                    fish.SetFishInfo(___fishInfo);
                }

                if (settings.PlayHereFishy && fishyClip != null)
                {
                    PlayClip(fishyClip, settings.HereFishyVolume, false);
                }

                Singleton <TaskRunner> .Self.RunDelayTask(fishyClip.length, true, delegate
                {
                    if (___hud == null)
                    {
                        return;
                    }

                    if (fish != null)
                    {
                        if (settings.PlayWee && weeClip != null)
                        {
                            PlayClip(weeClip, settings.WeeVolume, true, fish.transform);
                        }
                        __instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, fish);
                        origPos = (__instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance) as Fish_t).gameObject.transform.position;
                        flatPos = origPos;
                        Singleton <TaskRunner> .Self.StartCoroutine(FishJump(__instance));
                    }
                    else
                    {
                        Module <Player> .Self.actor.TryDoAction(ACType.Animation, ACTAnimationPara.Construct("Throw_2", null, null, false));

                        typeof(FishingSystem_t).GetMethod("FishingEnd", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { true, false });
                    }
                    //__instance.GetType().GetField("curFish", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, __instance.GetType().GetMethod("CreateFish", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[0]));
                    //typeof(FishingSystem_t).GetMethod("FishingBegin", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
                });

                return(false);
            }
예제 #19
0
        // generate a level based on the input leveldata and assign it as placedLevel, ready for referencing
        public bool Place(LevelData levelData)
        {
            if (levelData != null)
            {
                if (generatedLevel != null)
                {
                    bool vertsDifferen = levelData.moveVerticies != generatedLevel.levelData.moveVerticies;
                    Debug.Log("Destroy Old generated Level, verticies are different: " + vertsDifferen);
                    DestroyImmediate(generatedLevel.gameObject);
                    generatedLevel = null;
                }

                // create the base level gameobject, parent of all levelObjects
                GameObject generatedLevelGO;
                generatedLevelGO = new GameObject("Generated Level " + levelData.id);

                // add leveldatamono
                generatedLevel                    = generatedLevelGO.AddComponent <LevelDataMono>();
                generatedLevel.levelData          = levelData;
                generatedLevel.gameObject.tag     = "Level";
                generatedLevel.gameObject.layer   = LayerMask.NameToLayer("LevelMask");
                generatedLevel.transform.parent   = transform;
                generatedLevel.transform.position = transform.position;

                // create lists
                generatedLevel.turrets     = new List <Turret>();
                generatedLevel.portals     = new List <Portal>();
                generatedLevel.speedStrips = new List <SpeedStrip>();
                generatedLevel.attractors  = new List <Attractor>();
                generatedLevel.bouncers    = new List <Bouncer>();

                // add spawn
                Spawn spawn = (Spawn)Instantiate(spawnPrefab, Vector3.zero, Quaternion.identity);
                spawn.transform.parent = generatedLevel.transform;
                Vector2 spawnPos = new Vector3(levelData.objectData.spawnPosition.x, levelData.objectData.spawnPosition.y, levelObjectZ);
                print("spawnpos loading: " + spawnPos);
                spawn.transform.localPosition = spawnPos;
                generatedLevel.spawn          = spawn;

                // add finish
                Finish finish = (Finish)Instantiate(finishPrefab, Vector3.zero, Quaternion.identity);
                finish.transform.parent = generatedLevel.transform;
                Vector2 finishPos = new Vector3(levelData.objectData.finishPosition.x, levelData.objectData.finishPosition.y, levelObjectZ);
                finish.transform.localPosition = finishPos;
                generatedLevel.finish          = finish;

                // add turrets
                foreach (TurretData td in levelData.objectData.turretData)
                {
                    // create gameobject
                    Turret turret = (Turret)Instantiate(turretPrefab, Vector3.zero, Quaternion.identity);
                    turret.transform.parent = generatedLevel.transform;
                    Vector2 turretPos = new Vector3(td.position.x, td.position.y, levelObjectZ);
                    turret.transform.localPosition = turretPos;

                    turret.transform.rotation = Quaternion.Euler(td.rotation.x, td.rotation.y, td.rotation.z);

                    // assign values
                    turret.shotDelay    = td.shotDelay;
                    turret.startupDelay = td.startupDelay;
                    turret.constantFire = td.constantFire;
                    turret.shotSpeed    = td.shotSpeed;

                    generatedLevel.turrets.Add(turret);
                }

                // add attractors
                foreach (AttractorData ad in levelData.objectData.attractorData)
                {
                    // create gameobject
                    Attractor attractor = (Attractor)Instantiate(attractorPrefab, Vector3.zero, Quaternion.identity);
                    attractor.transform.parent = generatedLevel.transform;
                    Vector2 attractorPos = new Vector3(ad.position.x, ad.position.y, levelObjectZ);
                    attractor.transform.localPosition = attractorPos;

                    // assign values
                    attractor.pullRadius   = ad.radius;
                    attractor.maxPullForce = ad.pullStrength;
                    attractor.SetScale();

                    // add to the reference list for later saving access
                    generatedLevel.attractors.Add(attractor);
                }

                // add speedstrips
                foreach (SpeedStripData sd in levelData.objectData.speedStripData)
                {
                    // create gameobject
                    SpeedStrip speedStrip = (SpeedStrip)Instantiate(speedStripPrefab, Vector3.zero, Quaternion.identity);
                    speedStrip.transform.parent = generatedLevel.transform;
                    Vector2 speedStripPos = new Vector3(sd.position.x, sd.position.y, levelObjectZ);
                    speedStrip.transform.localPosition = speedStripPos;
                    speedStrip.transform.rotation      = Quaternion.Euler(sd.rotation.x, sd.rotation.y, sd.rotation.z);
                    speedStrip.accelSpeed = sd.pushStrength;
                    generatedLevel.speedStrips.Add(speedStrip);
                }

                // add bouncers
                foreach (BouncerData bd in levelData.objectData.bouncerData)
                {
                    Bouncer bouncer = (Bouncer)Instantiate(bouncerPrefab, Vector3.zero, Quaternion.identity);
                    bouncer.transform.parent = generatedLevel.transform;
                    Vector2 bouncerPos = new Vector3(bd.position.x, bd.position.y, levelObjectZ);
                    bouncer.transform.localPosition = bouncerPos;
                    bouncer.transform.rotation      = Quaternion.Euler(bd.rotation.x, bd.rotation.y, bd.rotation.z);
                    bouncer.bounciness = bd.bounciness;
                    bouncer.width      = bd.width;
                    generatedLevel.bouncers.Add(bouncer);
                }

                // add portals...
                foreach (PortalData pd in levelData.objectData.portalData)
                {
                    // create gameobject
                    Portal portal = (Portal)Instantiate(portalPrefab, Vector3.zero, Quaternion.identity);
                    portal.transform.parent = generatedLevel.transform;
                    Vector2 portalPos = new Vector3(pd.position.x, pd.position.y, levelObjectZ);
                    portal.transform.localPosition = portalPos;

                    // assign values
                    portal.portalID       = pd.portalID;
                    portal.linkedPortalID = pd.linkedPortalID;
                    portal.active         = pd.active;

                    generatedLevel.portals.Add(portal);
                }

                // ... and link them with one another - if there is no fitting counterpart, delete them
                foreach (Portal p in generatedLevel.portals)
                {
                    // get the portal that matches the linked id
                    Portal linkPortal = generatedLevel.portals.Find(x => x.portalID == p.linkedPortalID);
                    p.Link(linkPortal);

                    //// link both portals
                    //if (linkPortal != null)
                    //{
                    //    p.linkedPortal = linkPortal;
                    //    linkPortal.linkedPortal = p;
                    //}
                    //// no matching portal was found, linking not possible. Set this portal to inactive.
                    //else
                    //{
                    //    p.active = false;
                    //}
                }

                // create movearea
                MoveArea moveArea = (MoveArea)Instantiate(moveAreaPrefab, Vector3.zero, Quaternion.identity);
                moveArea.transform.parent        = generatedLevel.transform;
                moveArea.transform.localPosition = Vector3.zero;
                int length = levelData.moveVerticies.Length;
                generatedLevel.moveArea = moveArea;

                // if the leveldata has verticies listed, generate a mesh from it and place it
                if (length > 0)
                {
                    MeshFilter mr = moveArea.GetComponent <MeshFilter>();

                    Vector3[] verts = new Vector3[length];
                    for (int i = 0; i < length; i++)
                    {
                        verts[i] = new Vector3(levelData.moveVerticies[i].x, levelData.moveVerticies[i].y, moveAreaZ);
                    }
                    Mesh m = CreateMoveAreaMesh(verts, levelData.moveTriangles);
                    mr.sharedMesh = m;
                }
                // ... otherwise create a default level mesh and place it
                else
                {
                    MeshFilter mr = moveArea.GetComponent <MeshFilter>();

                    Vector3[] verts = new Vector3[4];
                    int[]     tri   = new int[6];

                    // upper left
                    verts[0] = Round(generatedLevel.moveArea.transform.InverseTransformPoint(new Vector3(3990f, 1110f, moveAreaZ)));
                    // upper right
                    verts[1] = Round(generatedLevel.moveArea.transform.InverseTransformPoint(new Vector3(4050f, 1110f, moveAreaZ)));
                    // lower left
                    verts[2] = Round(generatedLevel.moveArea.transform.InverseTransformPoint(new Vector3(3990f, 950f, moveAreaZ)));
                    // lower right
                    verts[3] = Round(generatedLevel.moveArea.transform.InverseTransformPoint(new Vector3(4050f, 950f, moveAreaZ)));

                    // create clockwise triangles based on the vertices we just created
                    tri[0] = 0;
                    tri[1] = 1;
                    tri[2] = 2;
                    tri[3] = 1;
                    tri[4] = 3;
                    tri[5] = 2;

                    Mesh m = CreateMoveAreaMesh(verts, tri);
                    mr.sharedMesh = m;
                    //LevelLoader.SaveCustomLevel(LevelEditor.CreateLevelData());
                }

                // set the movearea as the selected object
                if (Main.currentScene == Main.ActiveScene.editor)
                {
                    LevelEditor.SetSelectedObject(generatedLevel.moveArea);
                }
                return(true);
            }
            else
            {
                print("[LevelLoader] level already placed or the LevelData trying to be generated is null");
            }
            return(false);
        }