Наследование: TimedLife
Пример #1
0
        /*
         * This method is responsible for creating players. The types of players
         * as well as the controller and controller scheme are a must when calling
         * this method.
         * */
        private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme)
        {
            Element player;

            if (pacOrGhost == PlayerTypes.PacPlayer)
                player = new PacPlayer();
            else
                player = new Ghost();

            if (humanOrAI == PlayerTypes.Human)
            {
                if (controller == ControllerTypes.Keyboard)
                    player.AddController(new KeyboardController(scheme));
                else
                    player.AddController(new XboxController(scheme));
            }
            else
            {
                if (pacOrGhost == PlayerTypes.PacPlayer)
                    player.AddController(new PacplayerAIController());
                else
                    player.AddController(new GhostAIController());
            }

            players.Add(player);
        }
Пример #2
0
 public GhostPresenter(Game game, int i)
 {
     _game = game;
     _index = i;
     _current = null;
     _game.NotifyOn<Game>("Ghosts", delegate
     {
         if (_current != null)
             _current.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(_current_PropertyChanged);
              if (_index < _game.Ghosts.Count)
              {
                  _current = _game.Ghosts[_index];
              }
              else _current = null;
         if (_current != null)
             _current.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_current_PropertyChanged);
         NotifyPropertyChanged("Ghost");
     });
 }
Пример #3
0
    IEnumerator ProcessConsumedAfter(float delay, Ghost consumedGhost)
    {
        yield return(new WaitForSeconds(delay));

        //chowanie przyznanych pkt za zjedzenie duszka
        consumedGhostScoreText.GetComponent <Text>().enabled = false;
        //pokazanie ponownie pacmana i zjedzonych duchow
        GameObject pacMan = GameObject.Find("PacMan");

        pacMan.transform.GetComponent <SpriteRenderer>().enabled        = true;
        consumedGhost.transform.GetComponent <SpriteRenderer>().enabled = true;
        //wznowienie duchow
        GameObject[] i = GameObject.FindGameObjectsWithTag("Ghost");
        foreach (GameObject ghost in i)
        {
            ghost.transform.GetComponent <Ghost>().canMove = true;
        }
        //wznowienie pacmana
        pacMan.transform.GetComponent <PacMan>().canMove = true;
        //wznowienie muzyki w tle
        transform.GetComponent <AudioSource>().Play();

        didStartConsumed = false;
    }
Пример #4
0
    public void StartConsumed(Ghost consumedGhost)
    {
        if (!didStartConsumed)
        {
            didStartConsumed = true;

            //pauzowanie duchow
            GameObject[] i = GameObject.FindGameObjectsWithTag("Ghost");
            foreach (GameObject ghost in i)
            {
                ghost.transform.GetComponent <Ghost>().canMove = false;
            }

            //pauzowanie pacman
            GameObject pacMan = GameObject.Find("PacMan");
            pacMan.transform.GetComponent <PacMan>().canMove = false;
            //ukrycie pacmana
            pacMan.transform.GetComponent <SpriteRenderer>().enabled = false;
            //ukrywanie duchow
            consumedGhost.transform.GetComponent <SpriteRenderer>().enabled = false;
            //pauzowanie muzyki w tle
            transform.GetComponent <AudioSource>().Stop();

            Vector2 pos           = consumedGhost.transform.position;
            Vector2 viewPortPoint = Camera.main.WorldToViewportPoint(pos);
            consumedGhostScoreText.GetComponent <RectTransform>().anchorMin = viewPortPoint;
            consumedGhostScoreText.GetComponent <RectTransform>().anchorMax = viewPortPoint;

            consumedGhostScoreText.text = ghostConsumedRunningScore.ToString();

            consumedGhostScoreText.GetComponent <Text>().enabled = true;
            //dzwiek zjadania duszka
            transform.GetComponent <AudioSource>().PlayOneShot(consumedGhostAudioClip);
            StartCoroutine(ProcessConsumedAfter(0.75f, consumedGhost));
        }
    }
Пример #5
0
 void EngageGhost()
 {
     audio.clip   = ghostSound;
     audio.volume = 0.9f;
     audio.Play();
     Deactivate();
     ghost        = (Ghost)Instantiate(ghostPrefab, transform.position + transform.forward * GameController.Instance.ghostStartOffset, transform.rotation);
     ghost.player = this;
     ghost.guards = guards;
     cam.target   = ghost.transform;
     if (!GameController.Instance.timeMode)
     {
         GameController.Instance.DropChargeIncrement();
     }
     if (GameController.Instance.ghostMode)
     {
         AddTarget(ghost.transform);
     }
     else
     {
         AddPrimaryTarget(ghost.transform);
         RemoveTarget(transform);
     }
 }
Пример #6
0
    private void ShapeLanded(ref Shape activeShape, ref Ghost ghost, ref Spawner spawner, ref float timeToNextKeyLeftRight, ref float timeToNextKeyDown, ref float timeToNextKeyRotate)
    {
        activeShape.MoveUp();
        gameBoard.StoreShapeInGrid(activeShape);
        if (ghost)
        {
            ghost.Reset();
        }
        activeShape = spawner.SpawnShape();
        // resetting timings for input
        timeToNextKeyLeftRight = Time.time;
        timeToNextKeyDown      = Time.time;
        timeToNextKeyRotate    = Time.time;

        gameBoard.StartCoroutine("ClearAllRows");

        PlaySound(soundManager.dropSound, 0.75f);

        if (gameBoard.m_completedRows > 0)
        {
            scoreManager.ScoreLines(gameBoard.m_completedRows);
            if (gameBoard.m_completedRows > 1)
            {
                AudioClip randomVocal = soundManager.GetRandomClip(soundManager.vocalClips);
                PlaySound(randomVocal);
            }

            if (scoreManager.didLevelUp)
            {
                PlaySound(soundManager.levelUpClip);
                dropIntervalModded = Mathf.Clamp(dropInterval - (((float)scoreManager.level - 1f) * 0.1f), 0.05f, 1f);
            }

            PlaySound(soundManager.clearRowSound, 1f);
        }
    }
Пример #7
0
    IEnumerator ProcessConsumedAfter(float delay, Ghost consumedGhost)
    {
        yield return(new WaitForSeconds(delay));

        consumedGhostScoreText.GetComponent <Text>().enabled = false;

        GameObject pacMan = GameObject.Find("PacMan");

        pacMan.transform.GetComponent <PacMan>().canMove         = true;
        pacMan.transform.GetComponent <SpriteRenderer>().enabled = true;

        consumedGhost.transform.GetComponent <SpriteRenderer>().enabled = true;

        GameObject[] ghosts = GameObject.FindGameObjectsWithTag("Ghost");

        foreach (GameObject ghost in ghosts)
        {
            ghost.transform.GetComponent <Ghost>().canMove = true;
        }

        transform.GetComponent <AudioSource>().Play();

        didStartConsumed = false;
    }
Пример #8
0
    public void StartConsumed(Ghost consumedGhost)
    {
        if (!didStartConsumed)
        {
            didStartConsumed = true;

            GameObject[] ghosts = GameObject.FindGameObjectsWithTag("Ghost");

            foreach (GameObject o in ghosts)
            {
                o.transform.GetComponent <Ghost>().canMove = false;
            }

            GameObject PM = GameObject.Find("Pacman");
            PM.transform.GetComponent <SpriteRenderer>().enabled = false;
            PM.transform.GetComponent <PacMan>().canMove         = false;

            consumedGhost.transform.GetComponent <SpriteRenderer>().enabled = false;

            transform.GetComponent <AudioSource>().Stop();

            Vector2 pos           = consumedGhost.transform.position;
            Vector2 viewPortPoint = Camera.main.WorldToViewportPoint(pos);

            ghostScore.GetComponent <RectTransform>().anchorMin = viewPortPoint;
            ghostScore.GetComponent <RectTransform>().anchorMax = viewPortPoint;

            ghostScore.text = ghostCombo.ToString();

            ghostScore.GetComponent <Text>().enabled = true;

            transform.GetComponent <AudioSource>().PlayOneShot(ghostDeath);

            StartCoroutine(AfterConsumed(0.75f, consumedGhost));
        }
    }
Пример #9
0
        private static void DrawGhost(Ghost ghost)
        {
            ConsoleColor color;

            switch (ghost.Behaviour)
            {
            case Behaviour.Patrol: color = ConsoleColor.Red;
                break;

            case Behaviour.Frightened: color = ConsoleColor.Magenta;
                break;

            case Behaviour.Chase: color = ConsoleColor.Cyan;
                break;

            default: color = ConsoleColor.Red;
                break;
            }

            Console.SetCursorPosition((int)((ghost.GetLeft() + ghost.Size / 2) / (ghost.Size)),
                                      (int)((ghost.GetBottom() - ghost.Size / 2) / (ghost.Size)));
            Console.ForegroundColor = color;
            Console.Write('*');
        }
        public void BroadcastSpawnRequest(int?connection, Ghost instance, int prefabId, int instanceId)
        {
            var ownership = EOwnershipType.Server;

            foreach (var c in Server.Connections)
            {
                if (connection != null)
                {
                    ownership = c.InternalId == connection.Value ? EOwnershipType.Owner : EOwnershipType.Server;
                }

                var spawnRPCData = new SpawnRPCData
                {
                    InstanceId = instanceId,
                    PrefabId   = prefabId,
                    Ownership  = ownership,
                    Position   = instance.transform.position,
                    Rotation   = instance.transform.rotation,
                };

                var spawnRPC = RPCFactory.Create <SpawnRPC, SpawnRPCData>(spawnRPCData);
                Server.Write(spawnRPC, c);
            }
        }
Пример #11
0
        /// <summary>
        /// Update the current situation. This method MUST BE called at every tick of the game.
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        public void Update(GameTime gameTime)
        {
            if (PlayBeginning != -1)
            {
                // Every 5 secondes, the game releases a ghost
                if ((gameTime.TotalGameTime.TotalSeconds - PlayBeginning) != 0 &&
                    ((int)Math.Round(gameTime.TotalGameTime.TotalSeconds - PlayBeginning)) % COUNTDOWN_RELEASE_GHOST == 0)
                {
                    int index = (int)(gameTime.TotalGameTime.TotalSeconds - PlayBeginning) / COUNTDOWN_RELEASE_GHOST;

                    if (index > 0 && index < Ghosts.Count)
                    {
                        Ghost g = Ghosts[index];
                        if (g.State == GhostState.INITIALIZING)
                        {
                            g.State = GhostState.MOVING_MAZE;
#if DEBUG
                            Console.WriteLine("Ghost n°" + (index + 1) + " is released");
#endif
                        }
                    }
                }
            }
        }
Пример #12
0
        /// <summary>
        /// Mouse up function.
        /// </summary>
        /// <param name="document">Informations transferred from DrawingPanel.</param>
        /// <param name="e">MouseEventArgs.</param>
        public override void MouseUp(IDocument document, MouseEventArgs e)
        {
            base.MouseUp(document, e);

            if (_hitPosition == HitPositions.Center || _hitPosition == HitPositions.None)
            {
                return;
            }

            if (Select.LastSelectedShape == null)
            {
                return;
            }

            document.Shapes.Remove(Select.LastSelectedShape);
            Select.LastSelectedShape = Ghost.Shape.Clone() as IShape;
            document.Shapes.Add(Select.LastSelectedShape);
            Select.LastSelectedShape.Selected  = true;
            Select.LastSelectedShape.Locked    = false;
            Select.LastSelectedShape.Location  = Ghost.Shape.Location;
            Select.LastSelectedShape.Dimension = Ghost.Shape.Dimension;

            Ghost.MouseUp(document, e);
        }
Пример #13
0
        public override void Paint(Graphics g)
        {
            base.Paint(g);
            //Rectangle rectangle = WorkArea;
            //g.SetClip(WorkArea);
            g.Transform = ViewMatrix;
            //draw the ghost and ants on top of the diagram
            if (Ants != null)
            {
                Ants.Paint(g);
            }
            if (Ghost != null)
            {
                Ghost.Paint(g);
            }
            if (Tracker != null)
            {
                Tracker.Paint(g);
            }

            g.Transform.Reset();
            //g.PageUnit = GraphicsUnit.Pixel;
            //g.PageScale = 1.0F;
        }
Пример #14
0
    // Start is called before the first frame update
    void Awake()
    {
        //Create the starting noise, and the ghostchase sounds, and activate if on title.
        startingSound   = Instantiate(startingSound, new Vector3(0, 0, 0), Quaternion.identity);
        ghostChaseSound = Instantiate(ghostChaseSound, new Vector3(0, 0, 0), Quaternion.identity);
        if (gameObject.tag != "title")
        {
            startingSound.GetComponent <AudioSource>().enabled   = true;
            ghostChaseSound.GetComponent <AudioSource>().enabled = true;
            ghostTimer         = HUD.transform.GetChild(3).GetComponent <Text>();
            ghostTimer.enabled = false;
        }
        else
        {
            startingSound.GetComponent <AudioSource>().enabled   = false;
            ghostChaseSound.GetComponent <AudioSource>().enabled = false;
        }

        for (int i = 0; i < 4; i++)
        {
            GameObject newGhostShape = Instantiate(ghostPrimitive, new Vector3(position[i].x, position[i].y, 0), Quaternion.identity);
            newGhostShape.GetComponent <SpriteRenderer>().color = ghostColor[i];
            Ghost newGhost = new Ghost(newGhostShape, eyes, (int)scaredTimerLimit, i);
            if (gameObject.tag == "title")
            {
                newGhostShape.GetComponent <GhostController>().enabled = false;
            }
            else
            {
                newGhostShape.GetComponent <GhostController>().ghost      = newGhost;
                newGhostShape.GetComponent <GhostController>().aiVariant  = i;
                newGhostShape.GetComponent <GhostController>().spawnPoint = newGhostShape.transform.position;
            }
            ghosts.Add(newGhost);
        }
    }
Пример #15
0
        public Direction?GetNextDirection(Ghost ghost, Game game)
        {
            var placesCannotMove = game.Walls.AsEnumerable();

            if (_canWalkDoors)
            {
                placesCannotMove = placesCannotMove.Except(game.Doors);
            }
            var availableMoves = GetAvailableMovesForLocation(ghost.Location, placesCannotMove);

            availableMoves.Remove(ghost.Direction.Opposite());

            if (availableMoves.Count() == 1)
            {
                return(availableMoves.First());
            }

            var target = _directToLocation.GetLocation(game);

            return(availableMoves
                   .OrderBy(possibleDirection => (ghost.Location + possibleDirection) - target)
                   .ThenBy(p => (int)p)
                   .First());
        }
Пример #16
0
        public override void Draw()
        {
            SpriteBatch batch = Screen.ScreenManager.SpriteBatch;

            // draw the ghosts
            foreach (Ghost ghost in ghostQ)
            {
                Color ghostColor = new Color(new Vector4(1, 1, 1, ghost.alpha));
                Vector2 ghostPos = Screen.world.Project(ghost.pos);
                batch.Draw(ghostTexture, ghostPos, new Rectangle(0, 0, ghostTexture.Width, ghostTexture.Height),
                    ghostColor, 0, new Vector2(ghostTexture.Width / 2, ghostTexture.Height / 2), ghost.scale, SpriteEffects.None, 0);
            }

            // add a ghost
            if (++ghostCounter >= 4)
            {
                ghostCounter = 0;
                Ghost ghost = new Ghost(boid.Position);
                float fScale = MathHelper.Lerp(0, 1, boid.Speed / boid.MaxSpeed);
                ghost.alpha *= fScale;
                ghost.scale *= fScale;
                ghostQ.Enqueue(ghost);
            }
        }
Пример #17
0
        public static Color GetHairColor(On.Celeste.PlayerHair.orig_GetHairColor orig, PlayerHair self, int index)
        {
            Color          colorOrig = orig(self, index);
            Ghost          ghost     = self.Entity as Ghost;
            GhostNetClient client    = GhostNetModule.Instance.Client;
            uint           playerID;
            GhostNetFrame  frame;
            ChunkUUpdate   update;

            if (ghost == null ||
                client == null ||
                !client.GhostPlayerIDs.TryGetValue(ghost, out playerID) ||
                !client.UpdateMap.TryGetValue(playerID, out frame) ||
                (update = frame) == null)
            {
                return(colorOrig);
            }

            if (index < 0 || update.HairColors.Length <= index)
            {
                return(Color.Transparent);
            }
            return(update.HairColors[index]);
        }
Пример #18
0
        /*********
        ** Private methods
        *********/
        private void SpawnEntity(string command, string[] args)
        {
            //We need a world to spawn monsters in, duh
            if (Context.IsWorldReady)
            {
                // Determine if we have arguments
                if (args.Length > 0)
                {
                    //Set defaults
                    NPC entity = null;
                    int xTile  = Game1.player.getTileX();
                    int yTile  = Game1.player.getTileY();
                    int amount = 1;

                    //Ensure provided coordinatees are actually coordinates
                    try {
                        //Determine X tile
                        if (args.Length >= 2)
                        {
                            if (!args[1].Equals("~"))
                            {
                                xTile = int.Parse(args[1]);
                            }
                        }

                        //Determine Y tile
                        if (args.Length >= 3)
                        {
                            if (!args[1].Equals("~"))
                            {
                                yTile = int.Parse(args[2]);
                            }
                        }
                    } catch (Exception) {
                        Monitor.Log("Arguments 1 and 2 must be coordinates or '~' to use the Farmer's coordinates! Make sure you don't add any brackets!");
                        return;
                    }

                    try { if (args.Length >= 4)
                          {
                              amount = int.Parse(args[3]); if (amount < 1)
                              {
                                  throw new Exception();
                              }
                          }
                    } catch (Exception) { Monitor.Log("Argument 3 must be an amount larger than 0!"); return; }

                    Vector2 pos = new Vector2(xTile, yTile);

                    for (int i = 0; i < amount; i++)
                    {
                        // Determine the monster to spawn
                        switch (args[0])
                        {
                        case "greenSlime": entity = new GreenSlime(pos, 0); break;

                        case "blueSlime": entity = new GreenSlime(pos, 40); break;

                        case "redSlime": entity = new GreenSlime(pos, 80); break;

                        case "purpleSlime": entity = new GreenSlime(pos, 121); break;

                        case "yellowSlime": entity = new GreenSlime(pos, new Color(255, 255, 50)); break;

                        case "blackSlime": Random r = new Random();  entity = new GreenSlime(pos, new Color(40 + r.Next(10), 40 + r.Next(10), 40 + r.Next(10))); break;

                        case "bat": entity = new Bat(pos); break;                                                           //minelevel: 0 - 40 - 80 - 171 -> type

                        case "frostBat": entity = new Bat(pos, 40); break;

                        case "lavaBat": entity = new Bat(pos, 80); break;

                        case "iridiumBat": entity = new Bat(pos, 171); break;

                        case "bug": entity = new Bug(pos, 0); break;                                                                            //available areatypes: 121 -> armored

                        case "armoredBug": entity = new Bug(pos, 121); break;

                        case "fly": entity = new Fly(pos); break;                                                                                       //hard -> mutant

                        case "mutantFly": entity = new Fly(pos, true); break;

                        case "ghost": entity = new Ghost(pos); break;                                                                           //name -> carbon ghost

                        case "carbonGhost": entity = new Ghost(pos, "Carbon Ghost"); break;

                        case "grub": entity = new Grub(pos); break;                                                                                     //hard -> mutant

                        case "mutantGrub": entity = new Grub(pos, true); break;

                        case "rockCrab": entity = new RockCrab(pos); break;                                                 //name -> iridium crab

                        case "lavaCrab": entity = new LavaCrab(pos); break;

                        case "iridiumCrab": entity = new RockCrab(pos, "Iridium Crab"); break;

                        case "metalHead": entity = new MetalHead(pos, 80); break;                                           //mineareas: 0, 40, 80 - seems to only spawn at 80+

                        case "rockGolem": entity = new RockGolem(pos); break;                                               //mineareas: 0, 40, 80 - changes health and damage; difficultymod:

                        case "wildernessGolem": entity = new RockGolem(pos, 5); break;

                        case "mummy": entity = new Mummy(pos); break;

                        case "serpent": entity = new Serpent(pos); break;

                        case "shadowBrute": entity = new ShadowBrute(pos); break;

                        case "shadowShaman": entity = new ShadowShaman(pos); break;

                        case "skeleton": entity = new Skeleton(pos); break;

                        case "squidKid": entity = new SquidKid(pos); break;

                        case "duggy": entity = new Duggy(pos); break;

                        case "dustSpirit": entity = new DustSpirit(pos); break;
                        }
                        if (entity != null)
                        {
                            entity.currentLocation = Game1.currentLocation;
                            entity.setTileLocation(new Vector2(xTile, yTile));
                            Game1.currentLocation.addCharacter(entity);
                        }
                        else
                        {
                            Monitor.Log($"{args[0]} not found! Type monster_list to view a list of available monsters to spawn!"); return;
                        }
                    }
                    Monitor.Log($"{amount} {entity.Name} added at {entity.currentLocation.Name} {entity.getTileX()},{entity.getTileY()}", LogLevel.Info);
                }
                else
                {
                    Monitor.Log("Usage: monster_spawn <name> [posX] [posY] [amount]\n\nUses Farmer's coordinates if none or '~' was given.");
                }
            }
            else
            {
                Monitor.Log("Load a save first!");
            }
        }
Пример #19
0
 void Awake()
 {
     parent = GetComponentInParent<Ghost>();
 }
Пример #20
0
 protected override void OnGhostHit(Ghost ghost)
 {
     LevelController.current.elixirLost();
     CollectedHide();
 }
Пример #21
0
 public ModeChange(Ghost.Mode mode, int duration)
 {
     Duration = duration;
     Mode = mode;
 }
Пример #22
0
 public GhostHolder(Ghost ai, Vector3 resetPosition)
 {
     AI            = ai;
     ResetPosition = resetPosition;
 }
    override public void InitBehaviour(Ghost pGhost)
    {
        base.InitBehaviour(pGhost);

        pGhost.m_pProceduralVariablesModule.SetVariable(c_sVariableName_bCowardIsFleeing, false);
    }
Пример #24
0
        /// <summary>
        /// Load the map from the disk
        /// </summary>
        /// <returns>The loaded map</returns>
        /// <exception cref="InvalidDataException">The map has unrecognized character(s)</exception>
        public static GameMap LoadMap(string mapFile)
        {
            var      lines      = File.ReadAllLines(mapFile);
            var      dimensions = lines[0].Split(" ");
            var      width      = int.Parse(dimensions[0]);
            var      height     = int.Parse(dimensions[1]);
            Skeleton skeleton;
            Ghost    ghost;
            Ghost    ghosts;

            GameMap map = new GameMap(width, height, CellType.Empty);

            for (var y = 0; y < height; y++)
            {
                var line = lines[y + 1];
                for (int x = 0; x < width; x++)
                {
                    if (x < line.Length)
                    {
                        Cell cell = map.GetCell(x, y);
                        switch (line[x])
                        {
                        case ' ':
                            cell.Type = CellType.Empty;
                            break;

                        case '#':
                            cell.Type = CellType.Wall;
                            break;

                        case '.':
                            cell.Type = CellType.Floor;
                            break;

                        case 's':
                            cell.Type = CellType.Floor;
                            skeleton  = new Skeleton(cell);
                            map.Skeletons.Add(skeleton);
                            break;

                        case 'g':
                            cell.Type = CellType.Floor;
                            ghost     = new Ghost(cell);
                            map.Ghosts.Add(ghost);
                            break;

                        case 'l':
                            cell.Type = CellType.Floor;
                            ghosts    = new Ghost(cell);
                            map.GhostsSecond.Add(ghosts);
                            break;

                        case '@':
                            cell.Type  = CellType.Floor;
                            map.Player = new Player(cell);
                            Console.Write("Player health: ");
                            Console.Write(map.Player.Health);
                            break;

                        case 'k':
                            cell.Type     = CellType.Floor;
                            map.KeyToDoor = new KeyToDoor(cell);
                            break;

                        case '/':
                            cell.Type = CellType.Floor;
                            map.Sword = new Sword(cell);
                            break;

                        case 'd':
                            cell.Type = CellType.Floor;
                            map.Door  = new Door(cell);
                            break;

                        case 'D':
                            cell.Type  = CellType.Floor;
                            map.Dragon = new Dragon(cell);
                            break;

                        case 'S':
                            cell.Type  = CellType.Floor;
                            map.Stairs = new Stairs(cell);
                            break;

                        default:
                            throw new InvalidDataException($"Unrecognized character: '{line[x]}'");
                        }
                    }
                }
            }

            return(map);
        }
Пример #25
0
 void OnEnable()
 {
     if(parent == null) parent = transform.parent.gameObject.GetComponent<Ghost>();
     if(circleCollider2D == null) circleCollider2D = GetComponent<CircleCollider2D> ();
 }
Пример #26
0
 public Speedy(Ghost ghost) : base(ghost)
 {
 }
Пример #27
0
 public bool Chase(Ghost ghost)
 {
     return(base.ChaseCommon(ghost));
 }
Пример #28
0
    /* will be observing the status changes (of game mode and of ghost) */
    void Start()
    {
        _ghost = this.GetComponent <Ghost>();
        _eyes  = new List <GameObject> {
            upEye, rightEye, leftEye, downEye
        };

        /* Will adapt the eyes change according to ghost's direction */
        _ghost.SubscribeOnDirectionsChanges(direction => {
            _eyes.ForEach(eye => eye.SetActive(false));

            switch (direction)
            {
            case Direction.UP:
                upEye.SetActive(true);
                break;

            case Direction.RIGHT:
                rightEye.SetActive(true);
                break;

            case Direction.LEFT:
                leftEye.SetActive(true);
                break;

            case Direction.DOWN:
                downEye.SetActive(true);
                break;
            }
        });

        /* Will adapt the ghost's body according to his health condition */
        _ghost.SubscribeOnLifeStatusChange(isDead => {
            if (isDead)
            {
                body.SetActive(false);
                frightenedBody.SetActive(false);
                flashingBody.SetActive(false);
                eyeParent.SetActive(true);
            }
            else
            {
                body.SetActive(true);
                frightenedBody.SetActive(false);
                flashingBody.SetActive(false);
                eyeParent.SetActive(true);
            }
        });

        /* Will adapt the ghost's body according to GameMode */
        GameController.Instance.SubscribeForGameModeChanges(gameMode => {
            if (_ghost.isDead)
            {
                return;
            }

            if (gameMode.Equals(GameMode.FRIGHTENED))
            {
                body.SetActive(false);
                eyeParent.SetActive(false);
                frightenedBody.SetActive(true);
                flashingBody.SetActive(false);
            }
            else if (gameMode.Equals(GameMode.FRIGHTENED_FLASHING) && _ghost.isFrightened)
            {
                body.SetActive(false);
                eyeParent.SetActive(false);
                frightenedBody.SetActive(false);
                flashingBody.SetActive(true);
            }
            else
            {
                body.SetActive(true);
                eyeParent.SetActive(true);
                frightenedBody.SetActive(false);
                flashingBody.SetActive(false);
            }
        });
    }
Пример #29
0
 /// <summary>
 /// Called, when the palyer ate a ghost (while in frightened mode)
 /// </summary>
 public void GotGhost(Ghost ghost)
 {
     this._ghostKillCombo++;
     int worth = _killWorth[this._ghostKillCombo - 1];
     this._gameController.GhostConsumed(worth, ghost.transform.position);
 }
Пример #30
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     timer  = stateInfo.length;
     health = animator.GetComponent <HealthComponent>();
     enemy  = animator.GetComponent <Ghost>();
 }
Пример #31
0
 public static CollidedWithPacmanMessage Message(Ghost ghost)
 {
     _instance.Ghost = ghost;
       return _instance;
 }
Пример #32
0
 private void chasePosition(Ghost ghost)
 {
     base.SetTarget(ghost);
 }
Пример #33
0
 public ArmyTutorial(ContentManager content, string scenarioName, Ghost ghost, Mob mob, List <Ghost> allGhosts, GameStateMachine gameStateMachine)
     : base(content, scenarioName, ghost, mob)
 {
     this.goal      = new BoundingBox(new Vector3(1023, 120, 0), new Vector3(1103, 170, 0));
     this.allGhosts = allGhosts;
 }
Пример #34
0
        private Monster GetMonster(int x, Vector2 loc)
        {
            Monster m;

            switch (x)
            {
            case 0:
                m = new DustSpirit(loc);
                break;

            case 1:
                m = new Grub(loc);
                break;

            case 2:
                m = new Skeleton(loc);
                break;

            case 3:
                m = new RockCrab(loc);
                break;

            case 4:
                m = new Ghost(loc);
                break;

            case 5:
                m = new GreenSlime(loc);
                break;

            case 6:
                m = new RockGolem(loc);
                break;

            case 7:
                m = new ShadowBrute(loc);
                break;

            case 8:
                int y = rand.Next(1, 6);

                //m = new Monster();

                if (y == 1)
                {
                    m = new RockCrab(loc, "Iridium Crab");
                }
                else if (y == 2)
                {
                    m = new Ghost(loc, "Carbon Ghost");
                }
                else if (y == 3)
                {
                    m = new LavaCrab(loc);
                }
                //else if (y == 4)
                //m = new Bat(loc, Math.Max(Game1.player.CombatLevel * 5, 50));
                else if (y == 4)
                {
                    m = new GreenSlime(loc, Math.Max(Game1.player.CombatLevel * 5, 50));
                }
                else if (y == 5)
                {
                    m = new BigSlime(loc, Math.Max(Game1.player.CombatLevel * 5, 50));
                }
                else
                {
                    m = new Mummy(loc);
                }

                break;

            default:
                m = new Monster();
                break;
            }

            return(m);
        }
Пример #35
0
    public override void _Ready()
    {
        Cam = GetNode <Camera>("SteelCamera");

        ViewmodelItem = GetNode <MeshInstance>("SteelCamera/ViewmodelArmJoint/ViewmodelTiltJoint/ViewmodelItem");
        ViewmodelItem.RotationDegrees = new Vector3(0, 180, 0);
        ViewmodelItem.Hide();
        ViewmodelTiltJoint = GetNode <Position3D>("SteelCamera/ViewmodelArmJoint/ViewmodelTiltJoint");
        ViewmodelArmJoint  = GetNode <Position3D>("SteelCamera/ViewmodelArmJoint");
        ViewmodelArmJoint.RotationDegrees = new Vector3();
        NormalViewmodelArmX           = ViewmodelArmJoint.Translation.x;
        ViewmodelArmJoint.Translation = new Vector3(NormalViewmodelArmX, ViewmodelArmJoint.Translation.y, ViewmodelArmJoint.Translation.z);

        ProjectileEmitterHinge = GetNode <Spatial>("ProjectileEmitterHinge");
        ProjectileEmitter      = GetNode <Spatial>("ProjectileEmitterHinge/ProjectileEmitter");

        BodyCollision = GetNode <CollisionShape>("BodyCollision");
        BodyCapsule   = (CapsuleShape)BodyCollision.Shape;
        Assert.ActualAssert(BodyCapsule.Height == Height);

        if (Possessed)
        {
            Cam.MakeCurrent();
            GetNode <RayCast>("SteelCamera/RayCast").AddException(this);
            GetNode <Spatial>("BodyScene").Free();

            AddChild(HUDInstance);

            GhostInstance = (Ghost)GD.Load <PackedScene>("res://World/Ghost.tscn").Instance();
            GhostInstance.Hide();
            GetParent().CallDeferred("add_child", GhostInstance);

            SfxManager = GetNode <PlayerSfxManager>("PlayerSfxManager");
        }
        else
        {
            HeadJoint = GetNode("BodyScene").GetNode <Spatial>("HeadJoint");
            LegsJoint = GetNode("BodyScene").GetNode <Spatial>("LegsJoint");

            RightLegFlames = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/RightLegFlames");
            LeftLegFlames  = GetNode("BodyScene").GetNode <CPUParticles>("LegsJoint/LeftLegFlames");

            ThirdPersonItem = GetNode("BodyScene").GetNode <MeshInstance>("ItemMesh");
            ShaderMaterial Mat = new ShaderMaterial();
            Mat.Shader = Items.TileShader;
            ThirdPersonItem.MaterialOverride = Mat;

            Spatial Body = GetNode <Spatial>("BodyScene");
            Body.GetNode <HitboxClass>("BodyHitbox").OwningPlayer           = this;
            Body.GetNode <HitboxClass>("HeadJoint/HeadHitbox").OwningPlayer = this;
            Body.GetNode <HitboxClass>("LegsJoint/LegsHitbox").OwningPlayer = this;

            World.AddEntityToChunk(this);
            return;
        }

        Reset();

        if (Net.Work.IsNetworkServer())
        {
            SetFreeze(false);
            GiveDefaultItems();
        }

        World.AddEntityToChunk(this);
    }
Пример #36
0
 public virtual void AssignToGhost(Ghost ghost)
 {
     AssignedGhost = ghost;
 }
Пример #37
0
 public GhostHolder(Ghost ai, Vector3 resetPosition)
 {
     AI = ai;
     ResetPosition = resetPosition;
 }
Пример #38
0
 public override void AssignToGhost(Ghost ghost)
 {
     base.AssignToGhost(ghost);
 }
Пример #39
0
    private static Ghost parseGhost(XMLNode node, World world)
    {
        string name = "";
        if (node.attributes.ContainsKey("name"))
            name = node.attributes["name"];
        if (C.Save.requiredEnemyKills.Contains(name))
            return null;
        Ghost result = new Ghost(world, name);
        result.SetPosition((float.Parse(node.attributes["x"]) + 8f), -(float.Parse(node.attributes["y"]) - 8f));

        return result;
    }
Пример #40
0
 public EnemySpawnTutorial(ContentManager content, string scenarioName, Ghost ghost, Mob mob)
     : base(content, scenarioName, ghost, mob)
 {
     this.goal    = new BoundingBox(new Vector3(665, 440, 0), new Vector3(745, 510, 0));
     mob.Inactive = false;
 }
Пример #41
0
 public ActGhost( Ghost ghost )
     : base(ghost)
 {
 }
Пример #42
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Создание обьекта SpriteBatch для вывода 2D графики на экран.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            playerPacMan = new Player(Content.Load<Texture2D>("Pacman_HD"), new Rectangle(510, 490, 35, 35));  //500 501
            gameField = new Field(Content.Load<Texture2D>("fieldTile"), new Rectangle(0,0,35,35));
            fieldTileCenterTexture2D = Content.Load<Texture2D>("fieldTileCenter");

            fieldTileLeftTexture2D = Content.Load<Texture2D>("fieldTileLeft");
            fieldTileRightTexture2D = Content.Load<Texture2D>("fieldTileRight");

                ghostsRed = new Ghost(Content.Load<Texture2D>("GhostRed"), new Rectangle(455, 320, 35, 35));
                ghostsYellow = new Ghost(Content.Load<Texture2D>("GhostYellow"), new Rectangle(490, 320, 35, 35));
                ghostsBlue = new Ghost(Content.Load<Texture2D>("GhostBlue"), new Rectangle(525, 320, 35, 35));
                ghostsPink = new Ghost(Content.Load<Texture2D>("GhostPink"), new Rectangle(560, 320, 35, 35));

                ghostsRed.SetSpriteBanch(spriteBatch);
                ghostsYellow.SetSpriteBanch(spriteBatch);
                ghostsBlue.SetSpriteBanch(spriteBatch);
                ghostsPink.SetSpriteBanch(spriteBatch);

            playerPacMan.SetSpriteBanch(spriteBatch);

            playerPacMan.SetLeftImage(Content.Load<Texture2D>("Pacman_HD_left"));
            playerPacMan.SetRightImage(Content.Load<Texture2D>("Pacman_HD_right"));
            playerPacMan.SetDownImage(Content.Load<Texture2D>("Pacman_HD_down"));
            playerPacMan.SetUpImage(Content.Load<Texture2D>("Pacman_HD_up"));

            //CreateField();

            playerPacMan.SetCurrentField(gameField);
            ghostsRed.SetCurrentField(gameField);
            ghostsYellow.SetCurrentField(gameField);
            ghostsBlue.SetCurrentField(gameField);
            ghostsPink.SetCurrentField(gameField);

            // TODO: use this.Content to load your game content here
        }
Пример #43
0
 // Use this for initialization
 void Start()
 {
     parent = transform.parent.gameObject.GetComponent<Ghost>();
     script_SpriteStudio_Root = GetComponent<Script_SpriteStudio_Root>();
 }