Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        public static Grid CreateGameGrid(GameController controller, Cell[,] game)
        {
            Grid grid = new Grid();
            int createdColumns = 0;

            for (int row = 0; row < game.GetLength(0); row++)
            {
                grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(25, GridUnitType.Pixel) });

                for (int column = 0; column < game.GetLength(1); column++)
                {
                    // Create columns only once
                    if (createdColumns < game.GetLength(1))
                    {
                        grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(25, GridUnitType.Pixel) });
                        createdColumns++;
                    }

                    // Create cell controls
                    CellControl cell = new CellControl(controller, game[row, column]);

                    Grid.SetRow(cell, row);
                    Grid.SetColumn(cell, column);
                    grid.Children.Add(cell);
                }
            }

            return grid;
        }
Ejemplo n.º 2
0
 private CellControl lazySafeGetCellControl(Collision col)
 {
   if(null == _control)
   {
     _control = col.gameObject.GetComponent<CellControl>();
   }
   return _control;
 }
Ejemplo n.º 3
0
        private void RowControlDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var rowDataContext = e.NewValue as Y_NORM_NORMATIVE_ROW;

            foreach (Y_NORM_NORMATIVE_CELL cell in rowDataContext.Y_NORM_NORMATIVE_CELL.OrderBy(i => i.ID_COLUMN))
            {
                var cellControl = new CellControl {DataContext = cell};

                rowPanel.Children.Add(cellControl);
            }

            rowPanel.Children.Add(new RowUnitPanelControl {DataContext = DataContext, Name = "RowUnit"});
        }
Ejemplo n.º 4
0
 public static CellControl get() {
     if (_instance == null)
     {
         _instance = GameObject.Find(gameObjectName).GetComponent<CellControl>();
         if(null != _instance)
         {
             _instance.initializeIfNecessary();
         }
         else
         {
             Logger.Log("CellControl::get couldn't find game object", Logger.Level.ERROR);
         }
     }
     return _instance;
 }
Ejemplo n.º 5
0
 public static CellControl get()
 {
     if (_instance == null)
     {
         _instance = GameObject.Find(gameObjectName).GetComponent <CellControl>();
         if (null != _instance)
         {
             _instance.initializeIfNecessary();
         }
         else
         {
             Logger.Log("CellControl::get couldn't find game object", Logger.Level.ERROR);
         }
     }
     return(_instance);
 }
Ejemplo n.º 6
0
    // Use this for initialization
    void Awake()
    {
        GameObject       perso           = GameObject.Find(persoGameObjectName);
        Hero             hero            = perso.GetComponent <Hero>();
        PhenoFickContact pheno           = perso.GetComponent <PhenoFickContact>();
        GUITransitioner  guiTransitioner = GUITransitioner.get();
        CellControl      cellControl     = perso.GetComponent <CellControl>();

        //Cellcontrol connection
        guiTransitioner.control = cellControl;

        InterfaceLinkManager interfaceLinkManager = GameObject.Find(InterfaceLinkManager.interfaceLinkManagerGameObjectName).GetComponent <InterfaceLinkManager>();

        cellControl.absoluteWASDButton     = interfaceLinkManager.absoluteWASDButton;
        cellControl.leftClickToMoveButton  = interfaceLinkManager.leftClickToMoveButton;
        cellControl.relativeWASDButton     = interfaceLinkManager.relativeWASDButton;
        cellControl.rightClickToMoveButton = interfaceLinkManager.rightClickToMoveButton;

        cellControl.selectedKeyboardControlTypeSprite = interfaceLinkManager.selectedKeyboardControlTypeSprite;
        cellControl.selectedMouseControlTypeSprite    = interfaceLinkManager.selectedMouseControlTypeSprite;

        interfaceLinkManager.controlsArray.cellControl = cellControl;


        //Hero connections
        hero.lifeAnimation   = GameObject.Find("LifeLogo").GetComponent <LifeLogoAnimation>();
        hero.energyAnimation = GameObject.Find("EnergyLogo").GetComponent <EnergyLogoAnimation>();

        GameObject.Find("LifeIndicator").GetComponent <LifeIndicator>().hero     = hero;
        GameObject.Find("EnergyIndicator").GetComponent <EnergyIndicator>().hero = hero;
        guiTransitioner.hero = hero;


        //PhenoFickcontact connections
        //TODO use InterfaceLinkManager
        pheno.vectroPanel       = GameObject.Find("RoomMediumInfoBackgroundSprite").GetComponent <VectrosityPanel>();
        pheno.graphMoleculeList = GameObject.Find("MediumInfoPanelRoom").GetComponent <GraphMoleculeList>();


        //Main Camera
        guiTransitioner.mainBoundCamera = GameObject.Find("Main Camera").GetComponent <BoundCamera>();

        //MemoryManager reporting
        MemoryManager.get().hero = hero;
    }
Ejemplo n.º 7
0
        private void LoadCellControls()
        {
            var height = _configuration.Height;
            var width  = _configuration.Width;

            _fieldState   = new CellSign[height, width];
            _cellControls = new CellControl[height, width];
            for (var i = 0; i < height; ++i)
            {
                for (var j = 0; j < width; ++j)
                {
                    _cellControls[i, j] = new CellControl();
                    _cellControls[i, j].SetParams(i, j, ProcessCellClick);
                    FieldGrid.Children.Add(_cellControls[i, j]);
                    Grid.SetRow(_cellControls[i, j], i);
                    Grid.SetColumn(_cellControls[i, j], j);
                }
            }
        }
Ejemplo n.º 8
0
    }     // END Update

    void GenerateGrid()
    {
        for (int counterX = 0; counterX < 10; counterX++)
        {
            for (int counterY = 0; counterY < 10; counterY++)
            {
                cellX = counterX;
                cellY = counterY;

                cellNumber++;

                int        rowCellType = rnd.Next(0, 7);
                GameObject gObject     = (GameObject)GameObject.Instantiate(cellObject, new Vector3(0.5f * counterX, 0.5f * counterY, 0), new Quaternion(0f, 0f, 0f, 0f));

                CellControl gObjectCellControl = gObject.GetComponentInChildren <CellControl>();
                //gObjectCellControl.cellType = rowCellType;
                //gObjectCellControl.row = counterY;
                //gObjectCellControl.cellNumber = cellNumber;
            }
        }
    }
Ejemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        GameObject perso = GameObject.Find("Perso");

        if (null == perso)
        {
            Logger.Log("WorldLinkManager: error: Hero not found!", Logger.Level.ERROR);
        }

        mineManager.hero = perso.GetComponent <Hero> ();

        if (null != startPosition)
        {
            CellControl.get().teleport(startPosition.transform.position, startPosition.transform.rotation);
            startPosition.gameObject.SetActive(false);
        }

        //specific code for adventure1
        GameObject endGameColliderGameObject = GameObject.Find("TutoEnd");

        if (null != endGameColliderGameObject)
        {
            EndGameCollider endGameCollider = endGameColliderGameObject.GetComponent <EndGameCollider> ();
            endGameCollider.hero              = perso;
            endGameCollider.endInfoPanel      = GameStateController.get().endWindow;
            endGameCollider.endMainMenuButton = GameStateController.get().endMainMenuButton;
            Logger.Log("EndGameCollider.infoPanel" + endGameCollider.endInfoPanel, Logger.Level.INFO);
        }

        //specific code for adventure1
        GameObject tutoRFPGameObject = GameObject.Find("TutoRFP");

        if (null != tutoRFPGameObject && null != perso)
        {
            InfoWindowCollisionTrigger tutoRFP = tutoRFPGameObject.GetComponent <InfoWindowCollisionTrigger> ();
            tutoRFP.heroCollider = perso.GetComponent <CapsuleCollider> ();
        }
    }
Ejemplo n.º 10
0
    void respawnCoroutine(CellControl cc)
    {
        enableEyes(true);

        foreach (GameObject flagellum in _flagella)
        {
            flagellum.SetActive(true);
        }
        _flagella.Clear();

        iTween.ScaleTo(gameObject, _optionsIn);
        safeFadeTo(_optionsInAlpha);

        cc.enabled = true;
        foreach (PushableBox box in FindObjectsOfType(typeof(PushableBox)))
        {
            box.resetPos();
        }

        MineManager.isReseting = true;


        SavedCell savedCell = null;

        if (null != _lastNewCell)
        {
            savedCell = (SavedCell)_lastNewCell.GetComponent <SavedCell>();
            savedCell.resetCollisionState();
            gameObject.transform.position = _lastNewCell.transform.position;
            gameObject.transform.rotation = _lastNewCell.transform.rotation;
        }

        _isAlive = true;
        cc.reset();
        setLife(1f);

        StartCoroutine(popEffectCoroutine(savedCell));
    }
Ejemplo n.º 11
0
        private void BtnPlusPlusClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (rowPanel.Children[rowPanel.Children.Count - 2].GetType() == typeof (CellControl))
                {
                    var currentCellControl = (CellControl) rowPanel.Children[rowPanel.Children.Count - 2];
                    if (((Y_NORM_NORMATIVE_CELL) currentCellControl.DataContext).ID_PARAM == 0 ||
                        ((Y_NORM_NORMATIVE_CELL) currentCellControl.DataContext).PARAM_VALUE == null)
                    {
                        MessageBox.Show("Заполните предыдущую ячейку", "Ошибка", MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                        return;
                    }
                }
                var cell = new Y_NORM_NORMATIVE_CELL
                               {
                                   ID_COLUMN =
                                       IdGenerator.GetId(((Y_NORM_NORMATIVE_ROW) DataContext).Y_NORM_NORMATIVE_CELL)
                               };
                ((Y_NORM_NORMATIVE_ROW) DataContext).Y_NORM_NORMATIVE_CELL.Add(cell);
                ((Y_NORM_NORMATIVE_ROW) DataContext).MAX_COLUMN =
                    (short) ((Y_NORM_NORMATIVE_ROW) DataContext).Y_NORM_NORMATIVE_CELL.Count;
                var cellControl = new CellControl {DataContext = cell};
                if (rowPanel.Children[rowPanel.Children.Count - 2].GetType() == typeof (CellControl))
                {
                    ((CellControl) rowPanel.Children[rowPanel.Children.Count - 2]).CellController.IsUnLocked = false;
                }

                rowPanel.Children.Insert(rowPanel.Children.Count - 1, cellControl);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 12
0
    IEnumerator deathEffectCoroutine(CellControl cc)
    {
        cc.enabled = false;
        
        iTween.ScaleTo(gameObject, _optionsOut);

        safeFadeTo(_optionsOutAlpha);  

        _flagella = new List<GameObject>();

        foreach (Transform child in transform)
        {
            if(child.name == "FBX_flagelPlayer" && child.gameObject.activeSelf)
            {
                _flagella.Add(child.gameObject);
            }
        }
        
        //1 wait sequence between flagella, pair of eyes disappearances
        //therefore #flagella + #pairs of eyes - 1
        int maxWaitSequences = _flagella.Count;
        
        //fractional elapsed time
        // 0<elapsed<maxWaitSequences
        float elapsed = 0.0f;

        _flagella[0].SetActive(false);
        for(int i=1; i<_flagella.Count; i++)
        {
            //to make flagella disappear
            float random = UnityEngine.Random.Range(0.0f,1.0f);
            yield return new WaitForSeconds(random*_respawnTimeS/maxWaitSequences);
            _flagella[i].SetActive(false);
            elapsed += random;
        }

        //to make eyes disappear
        float lastRandom = UnityEngine.Random.Range(0.0f,1.0f);
        yield return new WaitForSeconds(lastRandom*_respawnTimeS/maxWaitSequences);
        elapsed += lastRandom;        
        enableEyes(false);

        yield return new WaitForSeconds((maxWaitSequences-elapsed)*_respawnTimeS/maxWaitSequences);
        
        respawnCoroutine(cc);
    }
Ejemplo n.º 13
0
    private void Drilling()
    {
        if (drillingDepthCurrent <= drillingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity            
                GameObject layer = null;
                CellControl cell = null;
                Vector3 newPos;
                GameObject newDrill;

                drillingDepthCurrent++;
                timer = timerIntervallDrilling;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell = layer.GetComponent<CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1)) break;
                }

                try
                {
                    newPos = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabDrillObject.transform.position.z);
                    newDrill = (GameObject)Instantiate(prefabDrillObject, newPos, layer.transform.rotation);
                    newDrill.transform.parent = gameObject.transform.parent.transform;



                    drillList.Add(newDrill);
                    newDrill.transform.position = newPos;

                    if (cell.isHidden) { cell.isHidden = false; cell.LoadTexture(); }
                    if (!canDrill(cell)) { DestroyBuilding("Gestein zu Hart --> Abbruch"); }
                    else if (drillingDepthCurrent > drillingDepthGoal)
                    {

                        buildingStatus = BUILDINGSTATUS.Mining;
                        miningCell = layer;
                        miningCellControl = cell;
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;

                }
            }
        }
    }
Ejemplo n.º 14
0
 bool canDrill(CellControl cellControl)
 {
     switch (drillType)
     {
         case BOHRERART.Standard:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser)
             { return true; }
             break;
         case BOHRERART.Eisen:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                 cellControl.bodenart == CellControl.BODENARTEN.Gold)
             { return true; }
             break;
         case BOHRERART.Stahl:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                 cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                 cellControl.bodenart == CellControl.BODENARTEN.Oel)
             { return true; }
             break;
         case BOHRERART.Chrom:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                 cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                 cellControl.bodenart == CellControl.BODENARTEN.Oel)
             { return true; }
             break;
         case BOHRERART.Titan:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                 cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                 cellControl.bodenart == CellControl.BODENARTEN.Oel ||
                 cellControl.bodenart == CellControl.BODENARTEN.Obsidian ||
                 cellControl.bodenart == CellControl.BODENARTEN.Marmor ||
                 cellControl.bodenart == CellControl.BODENARTEN.Diamant)
             { return true; }
             break;
         case BOHRERART.Diamant:
             if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                 cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                 cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                 cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                 cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                 cellControl.bodenart == CellControl.BODENARTEN.Oel ||
                 cellControl.bodenart == CellControl.BODENARTEN.Magma ||
                 cellControl.bodenart == CellControl.BODENARTEN.Obsidian ||
                 cellControl.bodenart == CellControl.BODENARTEN.Marmor ||
                 cellControl.bodenart == CellControl.BODENARTEN.Diamant)
             { return true; }
             break;
     }
     return false;
 }
Ejemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        if (isShortcutKeyDown(KeyCode.X))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the pursuit", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(500, 0, 637));
        }
        else if (isShortcutKeyDown(KeyCode.V))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the GFP BioBrick", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(168, 0, 724));
        }
        else if (isShortcutKeyDown(KeyCode.W))
        {
            Logger.Log("pressed shortcut to teleport Cellia to the end of the game", Logger.Level.INFO);
            CellControl.get().teleport(new Vector3(-150, 0, 1110));
        }

        switch (_gameState)
        {
        case GameState.Start:

            endWindow.SetActive(false);
            mainMenu.setNewGame();
            if (GameConfiguration.RestartBehavior.GAME == MemoryManager.get().configuration.restartBehavior)
            {
                leaveMainMenu();
            }
            else
            {
                goToMainMenuFrom(GameState.Game);
            }
            break;

        case GameState.MainMenu:
            if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                mainMenu.selectPrevious();
            }
            else if (Input.GetKeyUp(KeyCode.DownArrow))
            {
                mainMenu.selectNext();
            }
            else if (Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.KeypadEnter))
            {
                mainMenu.getCurrentItem().click();
            }
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                mainMenu.escape();
            }
            break;

        case GameState.Game:

            prepareGameLevelIfNecessary();

            //pause
            if (isShortcutKeyDown(_pauseKey))
            {
                Logger.Log("GameStateController::Update - Escape/Pause key pressed", Logger.Level.DEBUG);
                ModalManager.setModal(pauseIndicator, false);
                changeState(GameState.Pause);
            }
            //main menu
            else if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.Game);
            }
            //inventory
            //TODO add DNA damage accumulation management when player equips/unequips too often
            else if (isShortcutKeyDown(_inventoryKey) && Inventory.isOpenable())
            {
                Logger.Log("GameStateController::Update inventory key pressed", Logger.Level.INFO);
                gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen2);
            }
            //crafting
            else if (isShortcutKeyDown(_craftingKey) && CraftZoneManager.isOpenable())
            {
                Logger.Log("GameStateController::Update craft key pressed", Logger.Level.INFO);
                gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen3);
            }

            /*
             * else if(isShortcutKeyDown(_sandboxKey))
             * {
             *  Logger.Log("GameStateController::Update sandbox key pressed from scene="+MemoryManager.get ().configuration.getSceneName(), Logger.Level.INFO);
             *  goToOtherGameMode();
             * }*/
            //TODO fix this feature

            /*
             * else if(isShortcutKeyDown(_forgetDevicesKey))
             * {
             *  Inventory.get ().switchDeviceKnowledge();
             * }*/
            break;

        case GameState.Pause:
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.Pause);
            }
            else
            {
                GameStateTarget newState = ModalManager.manageKeyPresses();
                if (GameStateTarget.NoAction != newState)
                {
                    if (
                        GameStateTarget.NoTarget != newState &&
                        GameStateTarget.Pause != newState
                        )
                    {
                        changeState(getStateFromTarget(newState));
                    }
                }
                else
                {
                    switch (gUITransitioner._currentScreen)
                    {
                    case GUITransitioner.GameScreen.screen1:
                        break;

                    case GUITransitioner.GameScreen.screen2:
                        if (isShortcutKeyDown(_inventoryKey) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Return))
                        {
                            Logger.Log("GameStateController::Update out of inventory key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen1);
                        }
                        else if (isShortcutKeyDown(_craftingKey) && CraftZoneManager.isOpenable())
                        {
                            Logger.Log("GameStateController::Update inventory to craft key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen3);
                        }
                        break;

                    case GUITransitioner.GameScreen.screen3:
                        if (isShortcutKeyDown(_inventoryKey) && Inventory.isOpenable())
                        {
                            Logger.Log("GameStateController::Update craft to inventory key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen2);
                        }
                        else if (isShortcutKeyDown(_craftingKey) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyUp(KeyCode.KeypadEnter))
                        {
                            Logger.Log("GameStateController::Update out of craft key pressed", Logger.Level.INFO);
                            gUITransitioner.GoToScreen(GUITransitioner.GameScreen.screen1);
                        }
                        break;

                    default:
                        Logger.Log("GameStateController::Update unknown screen " + gUITransitioner._currentScreen, Logger.Level.WARN);
                        break;
                    }
                }
            }
            break;

        case GameState.End:
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                goToMainMenuFrom(GameState.End);
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 16
0
    private void Drilling()
    {
        if (drillingDepthCurrent <= drillingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity
                GameObject   layer    = null;
                CellControl  cell     = null;
                Vector3      newPos;
                GameObject   newDrill;

                drillingDepthCurrent++;
                timer = timerIntervallDrilling;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell  = layer.GetComponent <CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1))
                    {
                        break;
                    }
                }

                try
                {
                    newPos   = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabDrillObject.transform.position.z);
                    newDrill = (GameObject)Instantiate(prefabDrillObject, newPos, layer.transform.rotation);
                    newDrill.transform.parent = gameObject.transform.parent.transform;



                    drillList.Add(newDrill);
                    newDrill.transform.position = newPos;

                    if (cell.isHidden)
                    {
                        cell.isHidden = false; cell.LoadTexture();
                    }
                    if (!canDrill(cell))
                    {
                        DestroyBuilding("Gestein zu Hart --> Abbruch");
                    }
                    else if (drillingDepthCurrent > drillingDepthGoal)
                    {
                        buildingStatus    = BUILDINGSTATUS.Mining;
                        miningCell        = layer;
                        miningCellControl = cell;
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;
                }
            }
        }
    }
Ejemplo n.º 17
0
    private void Probing()
    {
        if (drillingDepthCurrent <= probingDepthGoal)
        {
            timer -= (1 * Time.deltaTime);

            if (timer <= 0)
            {
                RaycastHit[] hitEbene = Physics.RaycastAll(gameObject.transform.position, gameObject.transform.position * -1, 5, 1 << 8);//Mathf.Infinity
                GameObject   layer    = null;
                CellControl  cell     = null;
                Vector3      newPos;
                GameObject   newProbe;

                drillingDepthCurrent++;
                timer = timerIntervallProbing;

                for (int intEbene = 0; intEbene < hitEbene.Length; intEbene++)
                {
                    layer = hitEbene[intEbene].transform.parent.gameObject;
                    cell  = layer.GetComponent <CellControl>();

                    if (cell.lage == (20 - drillingDepthCurrent + 1))
                    {
                        break;
                    }
                }

                try
                {
                    newPos   = new Vector3(layer.transform.position.x, layer.transform.position.y, prefabProbeOject.transform.position.z);
                    newProbe = (GameObject)Instantiate(prefabProbeOject, newPos, layer.transform.rotation);

                    drillList.Add(newProbe);
                    newProbe.transform.position = newPos;


                    if (cell.isHidden)
                    {
                        cell.isHidden = false; cell.LoadTexture();
                    }
                    if (cell.lage >= 20 - probingShowAmountMax)
                    {
                        cell.showAmount = true;
                    }

                    if (drillingDepthCurrent > probingDepthGoal)
                    {
                        buildingStatus = BUILDINGSTATUS.Idle;
                        DestroyBuilding("Sondieren fertig");
                    }
                }
                catch
                {
                    DEBUG_GotException = true;
                    timer = 0;
                    drillingDepthCurrent--;
                }
            }
        }
    }
Ejemplo n.º 18
0
    void respawnCoroutine(CellControl cc)
    {
        enableEyes(true);
        
        foreach(GameObject flagellum in _flagella)
        {
            flagellum.SetActive(true);
        }
        _flagella.Clear();

        iTween.ScaleTo(gameObject, _optionsIn);
        safeFadeTo(_optionsInAlpha);  
        
        cc.enabled = true;      
        foreach (PushableBox box in FindObjectsOfType(typeof(PushableBox))) {
            box.resetPos();
        }

        MineManager.isReseting = true;


        SavedCell savedCell = null;
        if(null != _lastNewCell)
        {
            savedCell = (SavedCell)_lastNewCell.GetComponent<SavedCell>();
            savedCell.resetCollisionState();
            gameObject.transform.position = _lastNewCell.transform.position;
            gameObject.transform.rotation = _lastNewCell.transform.rotation;
        }
        
        _isAlive = true;
        cc.reset();
        setLife(1f);

        StartCoroutine(popEffectCoroutine(savedCell));
    }
Ejemplo n.º 19
0
    bool canDrill(CellControl cellControl)
    {
        switch (drillType)
        {
        case BOHRERART.Standard:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser)
            {
                return(true);
            }
            break;

        case BOHRERART.Eisen:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                cellControl.bodenart == CellControl.BODENARTEN.Gold)
            {
                return(true);
            }
            break;

        case BOHRERART.Stahl:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                cellControl.bodenart == CellControl.BODENARTEN.Oel)
            {
                return(true);
            }
            break;

        case BOHRERART.Chrom:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                cellControl.bodenart == CellControl.BODENARTEN.Oel)
            {
                return(true);
            }
            break;

        case BOHRERART.Titan:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                cellControl.bodenart == CellControl.BODENARTEN.Oel ||
                cellControl.bodenart == CellControl.BODENARTEN.Obsidian ||
                cellControl.bodenart == CellControl.BODENARTEN.Marmor ||
                cellControl.bodenart == CellControl.BODENARTEN.Diamant)
            {
                return(true);
            }
            break;

        case BOHRERART.Diamant:
            if (cellControl.bodenart == CellControl.BODENARTEN.Dreck ||
                cellControl.bodenart == CellControl.BODENARTEN.Kohle ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Stein ||
                cellControl.bodenart == CellControl.BODENARTEN.Erz ||
                cellControl.bodenart == CellControl.BODENARTEN.Wasser ||
                cellControl.bodenart == CellControl.BODENARTEN.Gold ||
                cellControl.bodenart == CellControl.BODENARTEN.Oel ||
                cellControl.bodenart == CellControl.BODENARTEN.Magma ||
                cellControl.bodenart == CellControl.BODENARTEN.Obsidian ||
                cellControl.bodenart == CellControl.BODENARTEN.Marmor ||
                cellControl.bodenart == CellControl.BODENARTEN.Diamant)
            {
                return(true);
            }
            break;
        }
        return(false);
    }
Ejemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        if (istAmBauen)
        {
            if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape))
            {
                Destroy(instanzGebaeude);
                istAmBauen      = false;
                instanzGebaeude = null;
                return;
            }

            Vector3 posMaus = camera.ScreenToWorldPoint(Input.mousePosition);
            Vector2 posNull = new Vector2(0, 0);

            float radius     = prefabGebaeude.transform.position.y;
            float winkel     = (Mathf.Atan((posNull.x - posMaus.x) / (posNull.y - posMaus.y)) * 180 / Mathf.PI);
            float winkelteil = 360f / 20f;           //ToDo die 20 ersetzten durch die echten teile
            float alphaD     = (2f * Mathf.PI) / 20; //ToDo die 20 ersetzten durch die echten teile


            if (posMaus.x >= posNull.x && posMaus.y <= posNull.y)
            {
                winkel = winkel * -1 + 180;                                                   //Q 1
            }
            else if (posMaus.x <= posNull.x && posMaus.y <= posNull.y)
            {
                winkel = (90 - winkel) + 90;                                                        //Q 2
            }
            else if (posMaus.x >= posNull.x && posMaus.y >= posNull.y)
            {
                winkel = (90 - winkel) + 270;                                                        //Q 3
            }
            else
            {
                winkel = winkel * -1;
            }

            int volleTeile = (int)(winkel / winkelteil);
            if (winkel % winkelteil >= (winkelteil / 2))
            {
                volleTeile += 1;
            }

            Vector3 newPosition = prefabGebaeude.transform.position;
            newPosition.x = Mathf.Cos((volleTeile + 5) * alphaD) * radius;
            newPosition.y = Mathf.Sin((volleTeile + 5) * alphaD) * prefabGebaeude.transform.position.y;

            Vector3 rayPosition = prefabGebaeude.transform.position;
            rayPosition.x = Mathf.Cos((volleTeile + 5) * alphaD) * (prefabGebaeude.transform.position.y + 1);
            rayPosition.y = Mathf.Sin((volleTeile + 5) * alphaD) * (prefabGebaeude.transform.position.y + 1);

            instanzGebaeude.transform.position         = newPosition;
            instanzGebaeude.transform.localEulerAngles = new Vector3(0, 0, volleTeile * winkelteil);


            //Debug.DrawRay(rayPosition, newPosition * -1, Color.black);

            RaycastHit rayHitOtherBuilding;

            instanzGebaeude.renderer.material.color = colorDeniedToBuild;

            if (!Physics.Raycast(rayPosition, newPosition * -1, out rayHitOtherBuilding, 1f))
            {
                RaycastHit rayHitGround;

                GameObject  groundCell      = null;
                CellControl groundCellInfos = null;

                //Debug.DrawRay(newPosition, newPosition * -1, Color.cyan);
                if (Physics.Raycast(newPosition, newPosition * -1, out rayHitGround, 1f))
                {
                    groundCell      = rayHitGround.transform.parent.gameObject;
                    groundCellInfos = (CellControl)groundCell.GetComponent <CellControl>();
                    //Debug.Log("Transform = " + groundCell.ToString());
                    //Debug.Log("ZellenTyp = " + groundCellInfos.bodenart.ToString());

                    if (groundCellInfos.bodenart != CellControl.BODENARTEN.Magma &&
                        groundCellInfos.bodenart != CellControl.BODENARTEN.Wasser &&
                        groundCellInfos.bodenart != CellControl.BODENARTEN.Oel)
                    {
                        instanzGebaeude.renderer.material.color = colorAllowedToBuild;


                        if (Input.GetMouseButton(0))
                        {
                            instanzGebaeude.transform.position      = new Vector3(instanzGebaeude.transform.position.x, instanzGebaeude.transform.position.y, 0);
                            instanzGebaeude.transform.parent        = worldGen.transform;
                            instanzGebaeude.collider.enabled        = true;
                            instanzGebaeude.renderer.material.color = colorInit;
                            istAmBauen      = false;
                            instanzGebaeude = null;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 21
0
 void Awake()
 {
     Logger.Log("CellControl::Awake", Logger.Level.INFO);
     CellControl.get();
 }
Ejemplo n.º 22
0
    //Respawn function after death
    IEnumerator RespawnCoroutine()
    {
        CellControl cc = GetComponent <CellControl>();

        yield return(StartCoroutine(deathEffectCoroutine(cc)));
    }
Ejemplo n.º 23
0
 public IEnumerable <IEnumerable <CellControl> > GetCellControls()
 {
     return(MazeMap.Select(line => line.Select(cell => CellControl.CreateCellControl(cell))));
 }