Ejemplo n.º 1
0
    public void onEnemyDefeat(EnemyGameObject enemy)
    {
        gameData.currEnemies.Remove(enemy);
        if (gameData.currEnemies.Count == 0)
        {
            Fight currentFight = GameData.getInstance().fightData.currentFight;
            deckService.discardHand();
            deckService.shuffleDiscardIntoDeck();
            deckService.onFightEnd();

            upgradeService.triggerCombatEndActions();

            sceneUiManager.showVictoryScene();
            if (currentFight.cardOnComplete)
            {
                cardUiManager.showCardSelectUi(cardGeneratorService.generateCards(3));
            }
            else
            {
                cardUiManager.destroyCardSelect();
            }
            if (currentFight.upgradeOnComplete)
            {
                upgradeUiManager.showUpgradeSelectUi(upgradeService.genRandomUpgrades(2));
            }
            else
            {
                upgradeUiManager.destroyUpgradeSelectUi();
            }
        }
    }
        private void canvas_CreateResources(ICanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args)
        {
            //Initialize image loader with canvas
            //TODO: The image manager may fail for multiple frames
            ImageManager.Initialize(sender);

            //Initialize game systems
            drawIndex    = new DrawableIndex();
            collisions   = new CollisionManager();
            gameObjects  = new GameObjectIndex(drawIndex, collisions);
            inputManager = new InputManager();
            players      = new PlayerRegistry();

            //Load the required images
            ImageManager.LoadImages(PacmanImagePaths.Images);

            //Register key event listeners
            Window.Current.CoreWindow.KeyDown += canvas_KeyDown;
            Window.Current.CoreWindow.KeyUp   += canvas_KeyUp;


            //Create a player
            player = new PlayerGameObject(new Vector2(200, 300), gameObjects, players, inputManager, KeyboardFormat.WASD);
            gameObjects.registerGameObject(player);


            //Create a dummy game object
            DummyGameObject testingObject = new DummyGameObject(new Vector2(100, 100), new Vector2(45, 45), gameObjects);

            //Register the new object in the game object index
            gameObjects.registerGameObject(testingObject);

            //Register the new object as an input listener
            inputManager.registerInputSource(new PlayerKeyboardInputSource(testingObject, KeyboardFormat.ARROWS));

            //Enable debug drawing
            drawIndex.SetDebugDrawing(true);

            //Add a wall
            WallGameObject wall = new WallGameObject(new Vector2(100, 100), new Vector2(150, 200));

            gameObjects.registerGameObject(wall);
            WallGameObject wall2 = new WallGameObject(new Vector2(150, 200), new Vector2(350, 250));

            gameObjects.registerGameObject(wall2);
            WallGameObject wall3 = new WallGameObject(new Vector2(300, 100), new Vector2(350, 200));

            gameObjects.registerGameObject(wall3);

            //Add an enemy object
            EnemyGameObject enemy = new EnemyGameObject(new Vector2(300, 300), gameObjects, new Random());

            enemy.Target = player;
            gameObjects.registerGameObject(enemy);
        }
Ejemplo n.º 3
0
    public Card getModifiedEnemyTurn(EnemyGameObject enemyGameObject)
    {
        Card modifiedEnemyTurn = stackCardAffects(enemyGameObject.enemy.data.enemyTurnData.enemyModifiers);

        if (StatusUtils.getAppliedStatusCount(StatusTypes.StatusEnum.weak, enemyGameObject.statusesObject.activeStatuses) > 0)
        {
            modifiedEnemyTurn.data.attack = (int)(modifiedEnemyTurn.data.attack * enemyGameObject.enemy.data.weakMultiplier);
        }

        return(modifiedEnemyTurn);
    }
 internal void StartGame()
 {
     var batwing = new BatwingGameObject()
     {
         Position = new Position(50, 150),
         Bouns = new Size(30, 70)
     };
     var enemy = new EnemyGameObject()
     {
         Position = new Position(800, 500),
         Bouns = new Size(30, 45)
     };
     var projectile = new ProjectileGameObject()
     {
         Position = new Position(450, 450),
         Bouns = new Size(50, 10)
     };
     this.renderer.Draw(batwing,enemy,projectile);
 }
Ejemplo n.º 5
0
        //Spawns an enemy
        public void SpawnEnemy()
        {
            //Generate a random position
            Vector2 randomPosition = new Vector2(randomNumbers.Next(30, 500), randomNumbers.Next(30, 500));

            //Create a new enemy
            EnemyGameObject enemy = new EnemyGameObject(randomPosition, gameObjects, randomNumbers);

            gameObjects.registerGameObject(enemy);

            //If there are players
            if (!players.IsEmpty())
            {
                //Get a random player
                PlayerGameObject randomPlayer = players.GetRandom() as PlayerGameObject;

                //Assign a random player as a target
                enemy.Target = randomPlayer;
            }
        }
        internal void StartGame()
        {
            var batwing = new BatwingGameObject()
            {
                Position = new Position(50, 150),
                Bouns    = new Size(30, 70)
            };
            var enemy = new EnemyGameObject()
            {
                Position = new Position(800, 500),
                Bouns    = new Size(30, 45)
            };
            var projectile = new ProjectileGameObject()
            {
                Position = new Position(450, 450),
                Bouns    = new Size(50, 10)
            };

            this.renderer.Draw(batwing, enemy, projectile);
        }
Ejemplo n.º 7
0
    public void initializeEnemiesForFight(Fight fight)
    {
        foreach (Transform child in enemyContainer.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        foreach (Enemy enemy in fight.enemies)
        {
            GameObject      enemyInstance      = GameObject.Instantiate(enemyObjectPrefab, new Vector3(0, 0, 0), Quaternion.identity);
            EnemyGameObject newEnemyGameObject = enemyInstance.GetComponent <EnemyGameObject>();
            newEnemyGameObject.initalize(enemyInstance, enemy);
            gameData.currEnemies.Add(newEnemyGameObject);
        }

        foreach (EnemyGameObject enemyGameObject in gameData.currEnemies)
        {
            enemyGameObject.transform.SetParent(enemyContainer.transform, false);
            enemyService.initializeEnemy(enemyGameObject);
        }
    }
Ejemplo n.º 8
0
 public void takeHit(EnemyGameObject enemyGameObject, int damage, int attackMultiplier)
 {
     if (damage <= 0)
     {
         return;
     }
     for (int i = 0; i < attackMultiplier; i++)
     {
         int modifiedDamage = damage + GameData.getInstance().playerGameObject.playerData.nextAttackBonusDamage;
         if (StatusUtils.getAppliedStatusCount(StatusTypes.StatusEnum.vulnerable, enemyGameObject.statusesObject.activeStatuses) > 0)
         {
             modifiedDamage = (int)(modifiedDamage * enemyGameObject.enemy.data.vulnerableMultiplier);
         }
         if (enemyGameObject.enemy.data.healthBarData.currBlock >= modifiedDamage)
         {
             enemyGameObject.enemy.data.healthBarData.currBlock -= modifiedDamage;
         }
         else
         {
             enemyGameObject.enemy.data.healthBarData.currHealth -= modifiedDamage - enemyGameObject.enemy.data.healthBarData.currBlock;
             enemyGameObject.enemy.data.healthBarData.currBlock   = 0;
         }
     }
 }
Ejemplo n.º 9
0
 public void onCardPlayed(EnemyGameObject enemyGameObject, Card card)
 {
     takeHit(enemyGameObject, card.data.attack, card.data.attackMultiplier);
     statusService.addStatuses(enemyGameObject.statusesObject, card.data.statuses, enemyGameObject.enemy.data);
 }
Ejemplo n.º 10
0
 public void onEnemyCardDrawn(EnemyGameObject enemyGameObject, Card card)
 {
     enemyGameObject.enemy.data.enemyTurnData.enemyModifiers.Add(card);
     enemyGameObject.enemy.data.enemyTurnData.currEnemyTurn = enemyTurnService.getModifiedEnemyTurn(enemyGameObject);
 }
Ejemplo n.º 11
0
 public void initializeEnemy(EnemyGameObject enemyGameObject)
 {
     enemyGameObject.enemy.data.initialize();
     enemyTurnService.updateEnemyTurn(enemyGameObject.enemy, 0);
 }
Ejemplo n.º 12
0
    public CardActions getCardInHandActions(CardGameObject cardGameObject)
    {
        CardActions actions = new CardActions();

        copyOverActions(cardGameObject, actions);
        Card       card            = cardGameObject.card;
        CardData   data            = card.data;
        Transform  transform       = cardGameObject.transform;
        bool       isDragging      = false;
        bool       isHovering      = false;
        Vector3    startPosition   = new Vector3(0, 0);
        GameObject backgroundImage = cardGameObject.transform.Find("cardBackground").gameObject;

        int yPositionForCardPlay = -250;

        actions.onDragStartAction = () =>
        {
            card.data.targetedEnemy = null;
            if (startPosition == null)
            {
                startPosition = cardGameObject.transform.position;
            }
            if (!(deckService.isCardPlayable(cardGameObject.card) && playerService.isCardPlayable(cardGameObject.card)))
            {
                backgroundImage.GetComponent <Image>().color = ColorUtils.cardUnplayable;
                return;
            }
            isDragging = true;
        };
        actions.onDragEndAction = () =>
        {
            isDragging = false;
            EnemyGameObject target = card.data.targetedEnemy;
            if (data.playerCardData.needsTarget && transform.position.y >= yPositionForCardPlay && target != null)
            {
                cardService.onCardPlayed(card);
                target.onNotTargeted();
                card.data.targetedEnemy = null;
                GameObject.Destroy(cardGameObject.gameObject);
            }
            else if (!data.playerCardData.needsTarget && transform.position.y >= yPositionForCardPlay)
            {
                cardService.onCardPlayed(card);
                GameObject.Destroy(cardGameObject.gameObject);
            }
            else
            {
                if (target != null)
                {
                    target.onNotTargeted();
                    card.data.targetedEnemy = null;
                }
                backgroundImage.GetComponent <Image>().color = ColorUtils.none;
                if (transform.position != startPosition)
                {
                    transform.localScale -= new Vector3(0.4f, 0.4f, 0);
                    transform.position    = startPosition;
                }
            }
        };
        actions.onUpdateAction = () =>
        {
            if (!isDragging || data.isEnemycard)
            {
                return;
            }

            EnemyGameObject target = card.data.targetedEnemy;
            if (transform.position.y >= yPositionForCardPlay && (!data.playerCardData.needsTarget || data.playerCardData.needsTarget && target != null))
            {
                backgroundImage.GetComponent <Image>().color = ColorUtils.cardPlayedGreen;
                if (target != null)
                {
                    target.onTargeted();
                }
            }
            else
            {
                backgroundImage.GetComponent <Image>().color = ColorUtils.white;
                if (target != null)
                {
                    target.onNotTargeted();
                }
            }
            RectTransform playerHandTransform = transform.parent.GetComponent <RectTransform>();
            transform.localPosition = new Vector2(Input.mousePosition.x - Screen.width / 2, Input.mousePosition.y - playerHandTransform.rect.height / 2);
        };
        actions.onTriggerEnter2DAction = (Collider2D other) =>
        {
            if (data.playerCardData.needsTarget)
            {
                EnemyGameObject curr = other.transform.gameObject.GetComponent <EnemyGameObject>();
                if (curr != null)
                {
                    card.data.targetedEnemy = curr;
                    curr.onTargeted();
                }
            }
        };
        actions.onTriggerExit2DAction = (Collider2D other) =>
        {
            EnemyGameObject target = card.data.targetedEnemy;
            if (target != null)
            {
                target.onNotTargeted();
            }
            card.data.targetedEnemy = null;
        };
        actions.onHoverEnter = () =>
        {
            if (isHovering)
            {
                return;
            }
            startPosition         = transform.position;
            transform.position   += new Vector3(0, 140, 0);
            transform.localScale += new Vector3(0.4f, 0.4f, 0);
            cardGameObject.GetComponent <Canvas>().overrideSorting  = true;
            cardGameObject.GetComponent <Canvas>().sortingOrder     = 10;
            cardGameObject.GetComponent <Canvas>().sortingLayerName = "UI";
            isHovering = true;
        };
        actions.onHoverExit = () =>
        {
            if (transform.position != startPosition)
            {
                transform.position   -= new Vector3(0, 140, 0);
                transform.localScale -= new Vector3(0.4f, 0.4f, 0);
            }
            cardGameObject.GetComponent <Canvas>().overrideSorting = false;
            isHovering = false;
        };
        return(actions);
    }