コード例 #1
0
ファイル: World.cs プロジェクト: Racaoma/mesmerized
        public PressurePlate GetNextPressurePlate(PressurePlate currentPressurePlate)
        {
            int i = 0;

            for (; i < pressurePlates.Length; i++)
            {
                if (pressurePlates[i] == currentPressurePlate)
                {
                    break;
                }
            }

            if (movementFlow == MovementFlowEnum.Clockwise)
            {
                return(pressurePlates[(i + 1) % pressurePlates.Length]);
            }
            else if (movementFlow == MovementFlowEnum.Counterclockwise)
            {
                i--;
                if (i < 0)
                {
                    i = pressurePlates.Length - 1;
                }

                return(pressurePlates[i]);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
 public void LoadMetaData()
 {
     if (requirements == null)
     {
         return;
     }
     foreach (RequirementsMetaData metaData in requirements)
     {
         Door doorComponent = Door.getDoorByPosition(new Vector2Int(metaData.doorToOpen));
         doorComponent.Setup(metaData,
                             metaData.openAutomatically);
         foreach (RequirementMetaData data in metaData.requirements)
         {
             if (data.type == 0)
             {
                 Key.getKeyByPosition(new Vector2Int(data.positionInGrid)).id = data.id;
             }
             else if (data.type == 1)
             {
                 PressurePlate.GetPressurePlateByPosition
                     (new Vector2Int(data.positionInGrid)).id = data.id;
             }
         }
     }
 }
コード例 #3
0
ファイル: Door.cs プロジェクト: Caillou1/ProtoInitenPuzzle
 public void Register(PressurePlate pp)
 {
     if (pressurePlates == null)
     {
         pressurePlates = new List <PressurePlate>();
     }
     pressurePlates.Add(pp);
 }
コード例 #4
0
    void InstantiatePressurePlate(Vector2Int position, int colCount, int rowCount)
    {
        GameObject pressurePlateGO = Instantiate(pressurePlatePrefab,
                                                 getWorldPosition(position.x, position.y, rowCount, colCount, -1),
                                                 pressurePlatePrefab.transform.rotation, contentParent);
        PressurePlate pressureComponent = pressurePlateGO.GetComponent <PressurePlate>();

        pressureComponent.Initialize(position);
    }
コード例 #5
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        PressurePlate pressurePlate = other.gameObject.GetComponent <PressurePlate>();

        if (pressurePlate != null && pressurePlate.Tangible)
        {
            pressurePlate.Activate();
        }
    }
コード例 #6
0
ファイル: PressurePlateText.cs プロジェクト: JordanTama/GDS2
    private void Awake()
    {
        _textMeshProUgui = GetComponent <TextMeshProUGUI>();
        if (interactableController is PressurePlate plate)
        {
            _pressurePlate = plate;
        }

        _pressurePlate.onCountChange             += SetText;
        _pressurePlate.OnInteractableStateChange += ChangeState;
    }
コード例 #7
0
        public void SetUp()
        {
            gameObject = new GameObject();

            pressurePlate = gameObject.AddComponent <PressurePlate>();
            gameObject.AddComponent <SpriteRenderer>();
            pressurePlate.linkedBlocks = new List <PressurePlateBlock>();
            pressurePlate.Start();

            pressurePlateRecorder = gameObject.AddComponent <PressurePlateRecorder>();
            pressurePlateRecorder.Start();
        }
コード例 #8
0
ファイル: Door.cs プロジェクト: Remmiemmyjr/PreCollege-Final
    private void UpdatePressurePlates()
    {
        listOfPlates.Clear();

        foreach (GameObject plate in pressurePlates)
        {
            //Hooks up pressureplate to door
            PressurePlate temp = plate.GetComponent <PressurePlate>();
            temp.Door = this.gameObject;
            listOfPlates.Add(temp);
        }
    }
コード例 #9
0
    private void LinkPlateByName(string s)
    {
        if (nPlates >= maxPlates)
        {
            return;
        }

        GameObject    go = GameObject.Find(s);
        PressurePlate pp = go.GetComponent <PressurePlate>();

        plates[nPlates++] = pp;
    }
コード例 #10
0
    private bool ScanPlatesActivated()
    {
        foreach (GameObject _pressurePlate in pressurePlatesList)
        {
            PressurePlate Pp = _pressurePlate.GetComponent <PressurePlate>();

            if (!Pp.plateStatus)
            {
                return(false); //if one plate still not activated, it will return false
            }
        }

        return(true); //if the plates are all activated, it will return true
    }
コード例 #11
0
 private void Awake()
 {
     boxCollider  = GetComponentInChildren <BoxCollider>();
     meshRenderer = GetComponentInChildren <MeshRenderer>();
     meshRenderer.material.SetColor(DissolveShaderBaseColor, baseColor);
     PressurePlate[] plates = FindObjectsOfType <PressurePlate>();
     for (int i = 0; i < plates.Length; ++i)
     {
         if (plates[i].code == code)
         {
             plate = plates[i];
         }
     }
 }
コード例 #12
0
        private IEnumerator ChangeGoalCoroutine(PressurePlate pressurePlate)
        {
            float timer = Random.Range(0f, maxDelayToWalk);

            while (timer > 0f)
            {
                timer -= Time.deltaTime;
                yield return(null);
            }

            Goal          = pressurePlate;
            _goalPosition = Goal.GetRandomPositionInside(_rangeRandomGoal) + agentOffset;
            _dirAgentGoal = this.transform.position - _goalPosition;
        }
コード例 #13
0
        public IActor Create(string actorType, string actorName, int x, int y)
        {
            IActor actor;

            if (actorType == "Player")
            {
                actor = new Player();
                actor.SetName(actorName);
                actor.SetPosition(x, y);

                return(actor);
            }
            else if (actorType == "Enemy")
            {
                actor = new Enemy();
                actor.SetName(actorName);
                actor.SetPosition(x, y);

                return(actor);
            }
            else if (actorType == "Switch")
            {
                actor = new Switch();
                actor.SetName(actorName);
                actor.SetPosition(x, y);

                return(actor);
            }
            else if (actorType == "Door")
            {
                actor = new Door();
                actor.SetName(actorName);
                actor.SetPosition(x, y);

                return(actor);
            }
            else if (actorType == "PressurePlate")
            {
                actor = new PressurePlate();
                actor.SetName(actorName);
                actor.SetPosition(x, y);

                return(actor);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
ファイル: PlatesList.cs プロジェクト: OhHiMerq/Game
    private bool ScanAllPlates()
    {
        foreach (GameObject Plates in ListOfPlates)
        {
            PressurePlate _plate = Plates.GetComponent <PressurePlate>();

            if (!_plate.GetActivateInfo)
            {
                return(false);
            }
        }

        //if all plates is activated
        return(true);
    }
コード例 #15
0
 public void resetRoom()
 {
     dispawnEnemies();
     GameObject[] toReset = GameObject.FindGameObjectsWithTag("Reset");
     foreach (GameObject g in toReset)
     {
         PressurePlate p = g.GetComponent <PressurePlate>();
         if (p != null)
         {
             p.Reset();
         }
     }
     objectsPrefabs.SetActive(false);
     InitializeRoom();
 }
コード例 #16
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="pressureplate">Pressure plate handle</param>
		/// <param name="dungeon">Maze maze handle</param>
		public PressurePlateControl(PressurePlate pressureplate, Maze maze)
		{
			if (maze == null)
				throw new ArgumentNullException("maze");

			InitializeComponent();

			ActionBox.Scripts = pressureplate.Scripts;
			ActionBox.Dungeon = maze.Dungeon;

			Maze = maze;
			DecorationSet = maze.Decoration;

			ActorPropertiesBox.Actor = pressureplate;
			PressurePlate = pressureplate;
		}
コード例 #17
0
    void IfPlayerIsHere()
    {
        Debug.Log("ATUALIZANDO PARTE 1");
        if (!complete)
        {
            if (lever.activated)
            {
                complete = true; lever.LeverDisable();
            }
            else
            {
                if (plate.activated)
                {
                    for (int i = 0; i < bridge1.Count; i++)
                    {
                        bridge1[i].GetComponent <Bridge>().Actived = true;
                    }
                }
                else
                {
                    for (int i = 0; i < bridge1.Count; i++)
                    {
                        bridge1[i].GetComponent <Bridge>().Actived = false;
                    }
                }
            }
        }
        else if (lever != null)
        {
            if (!gameManager.progressData.wayLesteP2)
            {
                gameManager.progressData.wayLesteP1 = true;
                gameManager.UpdateProgressSave();
            }
            lever = null;
            plate = null;
            for (int i = 0; i < bridge1.Count; i++)
            {
                bridge1[i].GetComponent <Bridge>().ForeverAtive = true;
                bridge2[i].GetComponent <Bridge>().enabled      = true;
                bridge2[i].GetComponent <Bridge>().ForeverAtive = true;
            }

            bridge1.Clear();
            bridge2.Clear();
        }
    }
コード例 #18
0
    public void OnSceneGUI()
    {
        Grid grid = BrushUtility.GetRootGrid(false);
        PressurePlateGate gate = brush.activeObject;

        if (grid == null || gate == null || gate.PressurePlate == null)
        {
            return;
        }

        PressurePlate plate            = gate.PressurePlate;
        Vector3       pressurePlatePos = grid.WorldToCellCentered(plate.transform.position);
        Vector3       doorPos          = grid.WorldToCellCentered(gate.transform.position);
        Color         color            = Color.red;

        BrushEditorUtility.DrawLine(grid, pressurePlatePos, doorPos, new Color(color.r, color.g, color.b, 0.5f));
    }
コード例 #19
0
ファイル: MazeStage.cs プロジェクト: bounoable/simulation
        void SpawnGoal(Maze maze)
        {
            PressurePlate prefab = Game.Prefabs.PressurePlate;
            MazeNode      node   = maze.RandomNode();

            Vector3 position = node.WorldPos + Vector3.down * node.Size.y * 0.5f;

            Game.Goal = MonoBehaviour.Instantiate(prefab, position, prefab.transform.rotation);

            node.OpenRandomSide(true);

            foreach (MazeNode neighbour in maze.GetNeighbours(node))
            {
                neighbour.OpenRandomSide(true);
            }

            Game.Grid.RecreateGrid();
        }
コード例 #20
0
    private void SpawnPlates()
    {
        float padding = 0.5f;

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Vector3 spawnPos = new Vector3(startX + x + padding, startY - y + padding, 0);
                //Debug.Log("SPAWNING at: " + spawnPos);

                GameObject    gameObject    = Instantiate(pressurePlatePrefab, spawnPos, Quaternion.identity);
                PressurePlate pressurePlate = gameObject.GetComponent <PressurePlate>();
                pressurePlate.Position   = new Vector2Int(x, y);
                pressurePlate.PuzzleName = "PressurePlatePuzzle";
            }
        }
    }
コード例 #21
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pressureplate">Pressure plate handle</param>
        /// <param name="dungeon">Maze maze handle</param>
        public PressurePlateControl(PressurePlate pressureplate, Maze maze)
        {
            if (maze == null)
            {
                throw new ArgumentNullException("maze");
            }

            InitializeComponent();

            ActionBox.Scripts = pressureplate.Scripts;
            ActionBox.Dungeon = maze.Dungeon;

            Maze          = maze;
            DecorationSet = maze.Decoration;

            ActorPropertiesBox.Actor = pressureplate;
            PressurePlate            = pressureplate;
        }
コード例 #22
0
	public void plateTriggered(PressurePlate.Symbol symbol) {
		switch(symbol) {
		case PressurePlate.Symbol.Earth:
			handleEarthSymbol();
			break;
			
		case PressurePlate.Symbol.Fire:
			handleFireSymbol();
			break;
			
		case PressurePlate.Symbol.Wind:
			handleWindSymbol();
			break;
			
		case PressurePlate.Symbol.Water:
			handleWaterSymbol();
			break;
		}
	}
コード例 #23
0
 public void Setup(RequirementsMetaData requirements,
                   bool openAutomatically)
 {
     this.openAutomatic = openAutomatically;
     keyIds             = new List <int>();
     pressurePlates     = new List <PressurePlate>();
     foreach (RequirementMetaData requirement in requirements.requirements)
     {
         if (requirement.type == 0)             // ITS A KEY
         {
             keyIds.Add(requirement.id);
         }
         else
         {
             pressurePlates.Add(PressurePlate.GetPressurePlateByPosition
                                    (new Vector2Int(requirement.positionInGrid)));
         }
     }
 }
コード例 #24
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))
        {
            playerManager.StepsTaken++;
            Vector3 OldPos = transform.position;
            MovePos();

            if (OldPos != transform.position)
            {
                if (StandingTile.ToggleType)
                {
                    PressurePlate pressurePlate = StandingTile.GetComponent <PressurePlate>();
                    pressurePlate.ToggleState();
                }
                else if (StandingTile.SpikeType)
                {
                    SpikeTile spike = StandingTile.GetComponent <SpikeTile>();
                    if (spike.State)
                    {
                        playerManager.GetHurt();
                    }
                }
                else if (StandingTile.KeyType)
                {
                    KeyTile key = StandingTile.GetComponent <KeyTile>();
                    TotalKeys = key.ToggleState(TotalKeys);
                }
                else if (StandingTile.ChestType)
                {
                    LockedChest chest = StandingTile.GetComponent <LockedChest>();
                    TotalKeys = chest.ToggleState(TotalKeys);
                }
                else if (StandingTile.EndType)
                {
                    EndTile Finish = StandingTile.GetComponent <EndTile>();
                    Finish.ToggleState();
                    MyFiredArrows?.Invoke();
                }
            }
        }
    }
コード例 #25
0
    public void destroyContent()
    {
        pool.returnAllObjects();
        wallPool.returnAllObjects();
        keyBoardOverlay.returnAllObjects();
        foreach (Transform t  in contentParent)
        {
            Destroy(t.gameObject);
        }
        Box.ClearList();
        Key.ClearList();
        Door.ClearList();
        PressurePlate.ClearList();
        LevelMetaData toDestroy = GetComponent <LevelMetaData> ();

        if (toDestroy != null)
        {
            DestroyImmediate(toDestroy);
        }
    }
コード例 #26
0
 public void UpdateButtonStates()
 {
     for (Int32 i = m_buttons.Count - 1; i >= 0; i--)
     {
         if (m_buttons[i] is Button)
         {
             Button button = (Button)m_buttons[i];
             if (button.UpdateTimer())
             {
                 m_buttons.RemoveAt(i);
             }
         }
         else if (m_buttons[i] is PressurePlate)
         {
             PressurePlate pressurePlate = (PressurePlate)m_buttons[i];
             if (pressurePlate.UpdateTimer())
             {
                 m_buttons.RemoveAt(i);
             }
         }
     }
 }
コード例 #27
0
        public void InitializePlates()
        {
            nbPlate = new PressurePlate
            {
                CarDirection = Direction.North
            };

            ebPlate = new PressurePlate
            {
                CarDirection = Direction.East
            };

            sbPlate = new PressurePlate
            {
                CarDirection = Direction.South
            };

            wbPlate = new PressurePlate
            {
                CarDirection = Direction.West
            };
        }
コード例 #28
0
        public void CheckStop(PressurePlate pressurePlate)
        {
            if (pressurePlate == Goal)
            {
                Pedestal.PressurePlateActiveItemEnum activeItem = pressurePlate.GetPressurePlateActiveItem();
                if (activeItem == Pedestal.PressurePlateActiveItemEnum.Dog && attitudeTowardDogs == AttitudeEnum.Fear)
                {
                    SetNextGoal(World.Instance.GetNextPressurePlate(Goal));
                    extraChanceToStop += 1f - baseChanceToStop;
                }
                else if (activeItem == Pedestal.PressurePlateActiveItemEnum.Lamp && attitudeTowardLight == AttitudeEnum.Attraction)
                {
                    return;
                }
                else if (activeItem == Pedestal.PressurePlateActiveItemEnum.Machine && attitudeTowardMachines == AttitudeEnum.Attraction)
                {
                    return;
                }
                else if (activeItem == Pedestal.PressurePlateActiveItemEnum.Robot)
                {
                    if (attitudeTowardRobots == AttitudeEnum.Fear)
                    {
                        SetNextGoal(World.Instance.GetNextPressurePlate(Goal));
                        extraChanceToStop += 1f - baseChanceToStop;
                    }
                    else if (attitudeTowardRobots == AttitudeEnum.Attraction)
                    {
                        return;
                    }
                }

                if (Random.Range(extraChanceToStop, 1f) <= baseChanceToStop)
                {
                    SetNextGoal(World.Instance.GetNextPressurePlate(Goal));
                    extraChanceToStop += _extraChanceToStopAfterNotStopping;
                }
            }
        }
コード例 #29
0
ファイル: NumberMaze.cs プロジェクト: Balobba/PuzzleGame
    private void SpawnMaze()
    {
        float padding = 0.5f;

        for (int x = 0; x < mazeSize; x++)
        {
            for (int y = 0; y < mazeSize; y++)
            {
                Vector3 spawnPos = new Vector3(startX + 2 * x + padding, startY - 2 * y + padding, 0);

                GameObject          gameObject = Instantiate(numberTilePrefab, spawnPos, Quaternion.identity);
                NumberSpriteHandler nsh        = gameObject.GetComponent <NumberSpriteHandler>();
                nsh.SetNumberSprite(layout[x, y]);
                nsh.Position       = new Vector2Int(2 * x, 2 * y);
                teleportList[x, y] = gameObject.transform.position;

                //Spawn the surrounding teleports
                if (x < mazeSize - 1)
                {
                    Vector3 eastSpawnPos = new Vector3(spawnPos.x + 1, spawnPos.y, 0);
                    gameObject = Instantiate(pressurePlatePrefab, eastSpawnPos, Quaternion.identity);
                    PressurePlate pressurePlate = gameObject.GetComponent <PressurePlate>();
                    pressurePlate.Position   = new Vector2Int(2 * x + 1, 2 * y);
                    pressurePlate.PuzzleName = "NumberMaze";
                }
                if (y < mazeSize - 1)
                {
                    Vector3 southSpawnPos = new Vector3(spawnPos.x, spawnPos.y - 1, 0);
                    gameObject = Instantiate(pressurePlatePrefab, southSpawnPos, Quaternion.identity);
                    PressurePlate pressurePlate = gameObject.GetComponent <PressurePlate>();
                    pressurePlate.Position   = new Vector2Int(2 * x, 2 * y + 1);
                    pressurePlate.PuzzleName = "NumberMaze";
                }
                //PressurePlate pressurePlate = gameObject.GetComponent<PressurePlate>();
                //pressurePlate.Position = new Vector2Int(x, y);
            }
        }
    }
コード例 #30
0
ファイル: Box.cs プロジェクト: Eden4897/Lost-In-The-Dungeons
    public override void OnMoved()
    {
        base.OnMoved();
        transform.parent = null;
        if (currentPlatform != null)
        {
            currentPlatform.gameElements.Remove(this);
        }
        if (currentPlate != null)
        {
            currentPlate.Release();
        }
        currentPlatform = null;
        currentPlate    = null;
        for (int i = 0; i < currentLasers.Count; ++i)
        {
            StartCoroutine(currentLasers[i].LaserCast());
        }
        currentLasers.Clear();
        Platform platform = grid.GetPlatform(position);

        if (platform != null)
        {
            transform.parent = platform.transform;
            platform.gameElements.Add(this);
            currentPlatform = platform;
        }

        PressurePlate plate = grid.GetPlate(position);

        if (plate != null)
        {
            plate.Step();
            currentPlate = plate;
        }
    }
コード例 #31
0
        public override void OnInspectorGUI()
        {
            PressurePlate plate = (PressurePlate)target;

            GUILayout.Label(plate.Interaction == null ? "Unlinked" : "Linked to " + plate.Interaction.name);

            if (GUILayout.Button("Link to closest Interaction Object"))
            {
                InteractionBase[] s = FindObjectsOfType <InteractionBase>();

                int   closest = -1;
                float dist    = float.MaxValue;

                for (int i = 0; i < s.Length; i++)
                {
                    float localDist = Vector3.Distance(plate.transform.position, s[i].transform.position);
                    if (localDist < dist)
                    {
                        closest = i;
                        dist    = localDist;
                    }
                }

                if (closest > -1)
                {
                    plate.Interaction = s[closest];
                    UnityEditor.PrefabUtility.RecordPrefabInstancePropertyModifications(plate);
                }
                else
                {
                    Debug.Log("No Storage found.");
                }
            }

            DrawDefaultInspector();
        }
コード例 #32
0
 public void Notify(PressurePlate plate) {
     entered_sequence[number_pressed] = plate;
     sfxok.Play();
     number_pressed += 1;
     for (int i = 0; i < number_pressed; i++) {
         if (entered_sequence[i] != sequence[i]) {
             if (entered_sequence[i] == sequence[0]) {
                 entered_sequence = new PressurePlate[sequence.Length];
                 entered_sequence[0] = sequence[0];
                 number_pressed = 1;
             } else {
                 entered_sequence = new PressurePlate[sequence.Length];
                 number_pressed = 0;
                 sfxko.Play();
             }
             return;
         }
     }
     if (number_pressed == sequence.Length) {
         manager.LevelComplete(2);
         complete = true;
         GetComponent<Animation>().Play();
     }
 }
コード例 #33
0
        public void Start()
        {
            // link components

            plate = GetComponent <PressurePlate>();
        }
コード例 #34
0
    IEnumerator ResetOff(PressurePlate plate)
    {
        yield return new WaitForSeconds(delayBeforeOff);

        plate.SetOnStatus(false);
    }