Example #1
0
 private void Start()
 {
     target = GameObject.FindWithTag("Player");
     Debug.Log(target);
     _rigidbody = GetComponent <Rigidbody>();
     _safeZone  = target.GetComponent <SafeZone>();
 }
Example #2
0
 // Use this for initialization
 void Start()
 {
     safeZone                   = FindObjectOfType <SafeZone>();
     safeZone.enabled           = false;
     gameController             = FindObjectOfType <GameController>();
     gameController.mouseBounds = bounds;
 }
Example #3
0
        private void Start()
        {
            Manager = GetComponent <ObjectiveManager>();
            var objectives = FindObjectsOfType <Target>().Select(x => {
                if (x.transform != null)
                {
                    return(x.transform);
                }
                else
                {
                    return(null);
                }
            }).Where(x => x != null).ToList();
            var rndmPos = objectives.ElementAtOrDefault(Random.Range(0, objectives.Count));

            var spawnPos = rndmPos != null && Random.Range(0, 10) >= 5f
                ? Utils.Utils.RandomPositionNear(rndmPos.position)
                : Utils.Utils.RandomPositionOnBoard();

            safeZone = Instantiate(Resources.Load <SafeZone>("SafeZone/SafeZone"), gameObject.transform, true);
            safeZone.transform.position = spawnPos;
            var scale = Random.Range(5, 15);

            safeZone.transform.localScale = new Vector3(scale, scale, 1);
            DisplayName = "Safe Zone";
        }
Example #4
0
    public void Start()
    {
        if (gameOverPanel != null)
        {
            gameOverPanel.SetActive(false);
        }

        _zones = GameObject.FindGameObjectsWithTag(
            "ScoreZone"
            ).ToList <GameObject>(
            ).ConvertAll <SafeZone>(
            (go) => go.GetComponent <SafeZone>()
            );

        _buildingMask = 1 << LayerMask.NameToLayer("Building");

        _bart          = GameObject.Find("Bart");
        _bartZone      = _bart.GetComponent <Enemy>().zone;
        _marge         = GameObject.Find("Marge");
        _margeZone     = _marge.GetComponent <Enemy>().zone;
        _moe           = GameObject.Find("Moe");
        _moeZone       = _moe.GetComponent <Enemy>().zone;
        _moeMovement   = _moe.GetComponent <Movement>();
        _burns         = GameObject.Find("Burns");
        _burnsZone     = _burns.GetComponent <Enemy>().zone;
        _burnsMovement = _burns.GetComponent <Movement>();

        _homerFactory = GameObject.Find("HomerFactory").GetComponent <HomerFactory>();

        const int  populationCount = 8;
        List <int> layers          = new List <int>();

        layers.Add(8);         // Input layer
        layers.Add(18);        // Hidden layer
        layers.Add(2);         // Output layer
        const double mutateChance                   = .4;
        const double mutateMaxFactor                = .4;
        const double migrationPercentage            = 0;
        const double childrenPercentage             = .19;
        const int    generations                    = 1000;
        Action <ANNTrainer, Action <double> > train = (ANNTrainer t, Action <double> callback) => {
            _nn       = t;
            _callback = callback;
            _startGame();
        };

        new EO(
            //populationCount,
            //layers,
            @"C:\Users\Public\EO\mc40mmf40mp0cp19g1000p8generation8.txt",
            mutateChance,
            mutateMaxFactor,
            migrationPercentage,
            childrenPercentage,
            generations,
            train
            );
    }
Example #5
0
    public void Start()
    {
        if (gameOverPanel != null) {

            gameOverPanel.SetActive(false);
        }

        _zones = GameObject.FindGameObjectsWithTag(
            "ScoreZone"
        ).ToList<GameObject>(
        ).ConvertAll<SafeZone>(
            (go) => go.GetComponent<SafeZone>()
        );

        _buildingMask = 1 << LayerMask.NameToLayer("Building");

        _bart = GameObject.Find("Bart");
        _bartZone = _bart.GetComponent<Enemy>().zone;
        _marge = GameObject.Find("Marge");
        _margeZone = _marge.GetComponent<Enemy>().zone;
        _moe = GameObject.Find("Moe");
        _moeZone = _moe.GetComponent<Enemy>().zone;
        _moeMovement = _moe.GetComponent<Movement>();
        _burns = GameObject.Find("Burns");
        _burnsZone = _burns.GetComponent<Enemy>().zone;
        _burnsMovement = _burns.GetComponent<Movement>();

        _homerFactory = GameObject.Find("HomerFactory").GetComponent<HomerFactory>();

        const int populationCount = 8;
        List<int> layers = new List<int>();
        layers.Add(8); // Input layer
        layers.Add(18); // Hidden layer
        layers.Add(2); // Output layer
        const double mutateChance = .4;
        const double mutateMaxFactor = .4;
        const double migrationPercentage = 0;
        const double childrenPercentage = .19;
        const int generations = 1000;
        Action<ANNTrainer, Action<double>> train = (ANNTrainer t, Action<double> callback) => {

            _nn = t;
            _callback = callback;
            _startGame();
        };

        new EO(
            //populationCount,
            //layers,
            @"C:\Users\Public\EO\mc40mmf40mp0cp19g1000p8generation8.txt",
            mutateChance,
            mutateMaxFactor,
            migrationPercentage,
            childrenPercentage,
            generations,
            train
        );
    }
Example #6
0
 public void Start()
 {
     safeZone         = FindObjectOfType <SafeZone>();
     safeZone.enabled = false;
     paciente         = zombie.GetComponent <Paciente>();
     paciente.setState(Paciente.State.DUMMY);
     zombie.GetComponent <Animator>().Play("idle");
     gameController             = FindObjectOfType <GameController>();
     gameController.mouseBounds = bounds;
 }
Example #7
0
    void Update()
    {
        if (!UnityEditor.EditorApplication.isPlaying)
        {
            Vector3[] bounds = SafeZone.Bounds(-2);

            Debug.DrawLine(bounds[0], bounds[1], Color.green);
            Debug.DrawLine(bounds[0], bounds[3], Color.green);
            Debug.DrawLine(bounds[2], bounds[1], Color.green);
            Debug.DrawLine(bounds[2], bounds[3], Color.green);
        }
    }
Example #8
0
    /* ActivateSafeZone()
     * ------------------
     * Instantiates the prefab that does the thing.
     *
     * Sets the prefab values from this function with the reference to it
     */
    public void ActivateSafeZone()
    {
        GameObject prefab = Instantiate(safeZonePrefab, transform);

        prefab.transform.parent = null;

        SafeZone safeZone = prefab.GetComponent <SafeZone>();

        safeZone.zoneBaseRadius     = zoneBaseRadius;
        safeZone.zoneMaxRadius      = zoneMaxRadius;
        safeZone.zoneDuration       = zoneDuration;
        safeZone.zoneRetainDuration = zoneRetainDuration;
    }
Example #9
0
        public MillingAttributes Initialize()
        {
            SafeSpeed   = SafeSpeed.CloneWithName <Speed>(nameof(SafeSpeed));
            PlungeSpeed = PlungeSpeed.CloneWithName <Speed>(nameof(PlungeSpeed));
            CutSpeed    = CutSpeed.CloneWithName <Speed>(nameof(CutSpeed));

            SafeZone   = SafeZone.CloneWithName <Zone>(nameof(SafeZone));
            PlungeZone = PlungeZone.CloneWithName <Zone>(nameof(PlungeZone));
            CutZone    = CutZone.CloneWithName <Zone>(nameof(CutZone));

            Frame = Frame.CloneWithName <Frame>(nameof(Frame));
            return(this);
        }
Example #10
0
    public ExtrusionAttributes Initialize()
    {
        SafeSpeed      = SafeSpeed.CloneWithName <Speed>(nameof(SafeSpeed));
        ApproachSpeed  = ApproachSpeed.CloneWithName <Speed>(nameof(ApproachSpeed));
        ExtrusionSpeed = ExtrusionSpeed.CloneWithName <Speed>(nameof(ExtrusionSpeed));

        SafeZone      = SafeZone.CloneWithName <Zone>(nameof(SafeZone));
        ApproachZone  = ApproachZone.CloneWithName <Zone>(nameof(ApproachZone));
        ExtrusionZone = ExtrusionZone.CloneWithName <Zone>(nameof(ExtrusionZone));

        Frame     = Frame.CloneWithName <Frame>(nameof(Frame));
        BeadWidth = Util.GetWidth(NozzleDiameter, LayerHeight);

        return(this);
    }
Example #11
0
    private void SpawnSafeZoneCampfire()
    {
        GeneratorGrid        grid         = GetComponent <GeneratorGrid>();
        List <GeneratorRoom> safeRoomList = grid.SafeRoomList;

        foreach (GeneratorRoom room in safeRoomList)
        {
            GeneratorChunk chunk = room.chunks[Random.Range(0, room.chunks.Count)];

            float x = Random.Range(chunk.Location.x * (int)grid.chunkSize, (chunk.Location.x + 1) * (int)grid.chunkSize);
            float y = Random.Range(chunk.Location.y * (int)grid.chunkSize, (chunk.Location.y + 1) * (int)grid.chunkSize);

            SafeZone newCampfireSafeZone = Instantiate(safeZoneCampfire, new Vector3(x, 0, y), Quaternion.identity) as SafeZone;
            newCampfireSafeZone.transform.SetParent(transform.parent);
        }
    }
Example #12
0
    // Update is called once per frame
    void Update()
    {
        if (!GameManager.manager.isPlaying)
        {
            return;
        }

        if (SafeZone.IsOffField(_transform.position))
        {
            Destroy(gameObject);
            return;
        }

        //print("_direction " + _direction + "_speedShot " + _speedShot + " Time.deltaTime " + Time.deltaTime + " scale : "+ Time.timeScale);
        _transform.Translate(_direction * _speedShot * Time.deltaTime);
    }
Example #13
0
    void Move()
    {
        Vector3 lMovement = Vector3.zero;

        float lXmovValue = Input.GetAxisRaw(_HORIZONTAL_AXIS);

        if (lXmovValue != 0)
        {
            lMovement += HorizontalMove(lXmovValue);
        }
        else if (_horizontalAccDecLerpValue != 0)
        {
            lMovement += HorizontalSlowDown();
        }

        float lYmovValue = Input.GetAxisRaw(_VERTICAL_AXIS);

        if (lYmovValue != 0)
        {
            lMovement += VerticalMove(lYmovValue);
        }
        else if (_verticalAccDecLerpValue != 0)
        {
            lMovement += VerticalSlowDown();
        }

        Vector2 lPoint = new Vector2(transform.position.x + lMovement.x, transform.position.y + lMovement.y);

        _flameAnimator.SetFloat("Vertical", _verticalAccDecLerpValue);
        _flameAnimator.SetFloat("Horizontal", _horizontalAccDecLerpValue);

        //if (SafeZone.IsOffField(lPoint)) return;

        if (SafeZone.IsOffFieldX(lPoint.x))
        {
            lMovement.x = 0;
        }
        if (SafeZone.IsOffFieldY(lPoint.y))
        {
            lMovement.y = 0;
        }
        if (lMovement != Vector3.zero)
        {
            AkSoundEngine.SetState("Moving_state", "yes");
            _transform.Translate(lMovement, Space.World);
        }
    }
Example #14
0
    private IEnumerator Die()
    {
        if (this.GetComponent <NavMeshAgent>().enabled)
        {
            this.GetComponent <NavMeshAgent>().enabled = false;
        }

        this.transform.Rotate(-75, 0, 0);
        yield return(new WaitForSeconds(1.5f));

        Hostage.SetActive(true);

        SafeZone sz = FindObjectOfType <SafeZone> ();

        if (sz != null)
        {
            sz.SetActive(true);
        }

        Wall.SetActive(false);

        Destroy(this.gameObject);
    }
Example #15
0
    void Generate()
    {
        int currentTotalLength = 0;
        int zoneLength         = 0;

        for (int i = 0; i < totalZoneAmount; i++)
        {
            if (i % 2 == 0)
            {
                zoneLength = UnityEngine.Random.Range(minSafeZoneLength, maxSafeZoneLength + 1);

                float initialZ;
                if (i == 0)
                {
                    initialZ = firstZoneZ;
                    zoneLength++;
                    currentTotalLength--;
                }
                else
                {
                    initialZ = initialZoneZ + currentTotalLength;

                    if (i == totalZoneAmount - 1)
                    {
                        zoneLength += lastZoneExtraLength;
                    }
                }

                zones.Add(Instantiate(safeZonePrefab, transform));
                SafeZone newZone = zones[zones.Count - 1].GetComponent <SafeZone>();
                if (newZone)
                {
                    newZone.Initialize(initialZoneX, initialZ, levelWidth, zoneLength);
                }
            }
            else
            {
                zoneLength = UnityEngine.Random.Range(minBaseDangerZoneLength, maxBaseDangerZoneLength + 1) + currentLevel;

                DangerZoneSO newZoneSO = dangerZoneSOs[UnityEngine.Random.Range(0, dangerZoneSOs.Count)];
                zones.Add(Instantiate(newZoneSO.prefab, transform));
                DangerZone newZone = zones[zones.Count - 1].GetComponent <DangerZone>();
                if (newZone)
                {
                    newZone.Initialize(initialZoneX, initialZoneZ + currentTotalLength, levelWidth, zoneLength);
                    newZone.SetType(newZoneSO.type);
                    newZone.SetObstacleValues(newZoneSO.minObstacleGenerationTime, newZoneSO.maxObstacleGenerationTime, newZoneSO.minObstacleSpeed, newZoneSO.maxObstacleSpeed);
                    newZone.SetListElements(newZoneSO.tilePrefabs, newZoneSO.obstaclePrefabs);

                    if (newZoneSO.type == DangerZoneTypes.Water)
                    {
                        newZone.SetWaterZoneTriggerPrefab(waterZoneTriggerPrefab);
                    }
                }
            }

            currentTotalLength += zoneLength;
        }

        GameObject levelEndTrigger = Instantiate(levelEndTriggerPrefab, transform);
        Vector3    size            = levelEndTrigger.GetComponent <BoxCollider>().size;

        size.x = levelWidth;
        levelEndTrigger.GetComponent <BoxCollider>().size = size;
        Vector3 position = levelEndTrigger.transform.position;

        position.z = currentTotalLength - zoneLength - 1f - tileOffset;
        levelEndTrigger.transform.position = position;
    }
Example #16
0
    private void Update()
    {
        if (safe)
        {
            return;
        }

        if (!canMove)
        {
            if (Physics2D.Raycast(transform.position, Vector2.right, SavingDistance, PlayerLayerMask))
            {
                canMove = true;
                Player.CiviliansFollowing.Add(this);
            }

            return;
        }

        var hit = Physics2D.Raycast(transform.position, Vector2.down, 2, SafeZoneLayerMask);

        if (hit)
        {
            SafeZone safeZone = hit.transform.GetComponent <SafeZone>();

            if (safeZone != null)
            {
                safe = true;

                GameController.CiviliansSaved++;
                GameController.OnSaveCivilian();

                civilianAnimations.CivilianAnimator.SetTrigger("Celebrate");

                Player.CiviliansFollowing.Remove(this);
            }
        }

        if (Vector2.Distance(transform.position, player.transform.position) > MinimumPlayerDistance)
        {
            RaycastHit2D hitRight = Physics2D.Raycast(transform.position, Vector2.right, RaycastDistance, PlayerLayerMask);
            RaycastHit2D hitLeft  = Physics2D.Raycast(transform.position, Vector2.left, RaycastDistance, PlayerLayerMask);

            if (hitRight)
            {
                translation = Vector2.right * Speed * Time.deltaTime;
                transform.Translate(translation);

                civilianAnimations.Parent.transform.eulerAngles = new Vector3(transform.rotation.x, 0f, transform.rotation.z);

                Velocity = 1;

                var playerHit = hitRight.transform.GetComponent <Player>();

                if (playerHit != null)
                {
                    transform.position = new Vector3(transform.position.x, player.transform.position.y);
                }
            }
            else if (hitLeft)
            {
                translation = Vector2.left * Speed * Time.deltaTime;
                transform.Translate(translation);

                civilianAnimations.Parent.transform.eulerAngles = new Vector3(transform.rotation.x, 180f, transform.rotation.z);

                Velocity = 1;

                var playerHit = hitLeft.transform.GetComponent <Player>();

                if (playerHit != null)
                {
                    transform.position = new Vector3(transform.position.x, player.transform.position.y);
                }
            }
            else
            {
                Velocity = 0;
            }
        }
        else
        {
            Velocity = 0;
        }

        var position = transform.position;

        Debug.DrawRay(position, Vector2.right * RaycastDistance, Color.red);
        Debug.DrawRay(position, Vector2.left * RaycastDistance, Color.red);
    }
Example #17
0
 private IEnumerator RestoreLastPlanet(float delay, SafeZone lastSafeZone)
 {
     yield return new WaitForSeconds(delay);
     mainCamera.CenterOn(lastSafeZone.gameObject, 0, false);
 }
Example #18
0
    // Update is called once per frame
    public void Update()
    {
        UpdateDeviceLost();
        if (!mainCam)
        {
            mainCam = Camera.main;
        }
        // 帧
        GameFrameManager.OnUpdate();
        // 定时器
        TimerManager.OnUpdate();
        DoTask();
        // 当前正在载入地图,不要处理消息
        if (loading != null)
        {
            if (!loading.isDone)
            {
                ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_PROGRESSING, (int)(loading.progress * 100));
                return;
            }
            else
            {
                loading = null;
                ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_PROGRESSING, 100);
                Trace.Log("load level asyn ok!");
            }
        }

        if (bCreated)
        {
            GameLogicAPI.onFrameUpdate();
        }
        FuntionShortCutCtrl nFunctionCtr = FuntionShortCutCtrl.GetInstance();

        if (InputManager.Raw_GetKeyUp(nFunctionCtr.GetKeyCodeByIndex(FuntionShortCutSlotIndex.ControlTraceOpen)))
        {
            if (!string.IsNullOrEmpty(LogFileName))
            {
                Process.Start(LogFileName);
            }
        }

        SkinManager.OnUpdate();
        SafeZone.Update();
        SafeZoneEffectManager.Update();
        if (isNeedToQuit)
        {
            bForbidQuit = false;
            Application.Quit();
        }


        if (NeedToReStart)
        {
            enabled       = false;
            NeedToReStart = false;
            ReStartApplication();
            return;
        }

        GUIDE.GuideManager.Update();

        // 通知逻辑层处理消息
        //ViewEventHelper.Instance.SendCommand(GameLogicDef.GVIEWCMD_FRAME_UPDATE);
    }
Example #19
0
 void Start()
 {
     //Create floating label
     cameraMatchRotationWhenSelected = false;
     Game.gui.labelPool.Label(gameObject,
                                 new Vector3(0, gameObject.transform.lossyScale.magnitude + 10, 0),
                                 planetInfo.planetName);
     builtStructures = new List<Structure>();
     territory = SafeZone.Spawn(territoryRadius, gameObject);
     territory.ShowRing();
 }