Exemplo n.º 1
0
 /**
  * Will set the Target of the Byte and will Deduct any points that will need to be Deducted as a result of the byte
  * Will Also Set the Animation to move towards the Byte target within the Fist half of the animation ime
  * @return The super.storedStateChangeObject as the change game state
  */
 private StateChange setByteTarget()
 {
     storedStateChangeObject.setToDefualts();
     bytePos = 0;
     if (currentTarget != null)
     {
         currentTarget.removeNode();
     }
     if (hostSet != null)
     {
         //choosing Target Enemy
         targetEnemyCollumn = getRandomCollomn();
         byteTarget         = hostSet.getEnemyAt(currentRow, targetEnemyCollumn);
         //Deducting Points
         if (byteTarget != this)
         {
             //Byte
             if (byteTarget != null && byteTarget.type != InteractableObject.ObjectType.CAT)
             {
                 if (byteTarget.isTypeRevealed)
                 {
                     storedStateChangeObject.changeInPlayerScore = -byteTarget.getScore();
                 }
                 if (byteTarget.type == InteractableObject.ObjectType.ANGRY)
                 {
                     storedStateChangeObject.add(((Ghost)byteTarget).getExplodeEffects());
                 }
             }
             //Move
             else if (byteTarget == null)
             {
                 hostSet.moveEnemy(this, currentRow, targetEnemyCollumn);
                 base.setAnimationTarget(currentRow, targetEnemyCollumn);
             }
             //Idle
             else
             {
                 targetEnemyCollumn = -1;
                 byteTarget         = null;
             }
             //is enemy already targeted
             if (isEnemyAlreadyTargeted(byteTarget))
             {
                 targetEnemyCollumn = -1;
                 byteTarget         = null;
             }
             //targeting enemy
             else
             {
                 currentTarget = targetEnemy(byteTarget);
             }
         }
         else
         {
             byteTarget = null;
         }
     }
     return(storedStateChangeObject);
 }
Exemplo n.º 2
0
 /**
  * will remove this Enemy From the currentEnemyGrid
  * Note this does Reset any previous changes to the stored storedStateChangeObject
  * before making its own changes
  */
 public override StateChange removeThis()
 {
     if (currentTarget != null)
     {
         currentTarget.removeNode();
         currentTarget = null;
     }
     byteTarget = null;
     this.targetEnemyCollumn = -1;
     return(base.removeThis());
 }
Exemplo n.º 3
0
 /**
  * Will add the given EnemySubSetNode to the list directly after this one
  */
 public void addNode(EnemySubSetNode newNode)
 {
     if (newNode != null)
     {
         newNode.previousNode = this;
         newNode.nextNode     = nextNode;
         if (nextNode != null)
         {
             nextNode.previousNode = newNode;
         }
         nextNode = newNode;
     }
 }
Exemplo n.º 4
0
        /** Stores previously removed nodes for reuse */

        /**
         * Will remove this node from the list and ling the node before and after this node togther
         */
        public void removeNode()
        {
            //removing this node
            if (nextNode != null)
            {
                nextNode.previousNode = previousNode;
            }
            if (previousNode != null)
            {
                previousNode.nextNode = nextNode;
            }
            previousNode = null;
            nextNode     = null;
        }
Exemplo n.º 5
0
        /**
         * Will remove all EnemySubSetNodes from the set
         * @param destroyData
         */
        public void removeAllEnemies(bool destroyData)
        {
            EnemySubSetNode target = firstNode.getNextNode();

            while (target != null)
            {
                EnemySubSetNode nextTarget = target.getNextNode();
                if (target.data != null && destroyData)
                {
                    target.data.removeThis();
                }
                target.removeNode();
                target = nextTarget;
            }
        }
Exemplo n.º 6
0
 /**
  * Will add a give baseEnemy to this set
  * Linked List. nothing fancy here
  * @param newEnemy
  */
 public EnemySubSetNode addEnemy(BaseEnemy newEnemy, bool informEnemy)
 {
     if (newEnemy != null)
     {
         EnemySubSetNode newNode = new EnemySubSetNode();
         newNode.data = newEnemy;
         if (informEnemy)
         {
             newEnemy.hostNode = newNode;
         }
         firstNode.addNode(newNode);
         return(newNode);
     }
     return(null);
 }
Exemplo n.º 7
0
 /**
  * Will Bite a Random Enemy on the current Row
  * @return the Score Decrement as a result of the Bite
  */
 private void BiteTarget(BaseEnemy target)
 {
     if (hostSet != null && target != null)
     {
         EnemySoundManager.requestSound(EnemySoundManager.SoundType.DRACKULA_ATTACK);
         //Target is Ghost
         //Making Angry
         if (target.type == InteractableObject.ObjectType.GHOST)
         {
             //if not revealed
             if (!target.isTypeRevealed)
             {
                 target.revealType(0);
             }
             ((Ghost)target).MakeAngry();
         }
         //Target is already an angry Ghost
         else if (target.type == InteractableObject.ObjectType.ANGRY)
         {
             //if not revealed
             if (!target.isTypeRevealed)
             {
                 target.revealType(0);
             }
             ((Ghost)target).explode();
             removeThis();
         }
         //Target is not an Angry Ghost
         //Removing Target and Making it an angry Ghost
         else if (target != this && target.type != InteractableObject.ObjectType.CAT)
         {
             target.removeThis();
             Ghost angryGhost = new Ghost(BaseCode.activeLibrary);
             angryGhost.revealType(0);
             hostSet.addEnemy(angryGhost, currentRow, targetEnemyCollumn);
             angryGhost.setCenter(base.getCenterX(), base.getCenterY());
             angryGhost.setAnimationTarget(currentRow, targetEnemyCollumn);
         }
     }
     if (currentTarget != null)
     {
         currentTarget.removeNode();
         currentTarget = null;
     }
     targetEnemyCollumn = -1;
 }
Exemplo n.º 8
0
        /**
         * Will attempt to find the given BaseEnemy in the set and if found will return the EnemySubSetNode that contains it.
         * Otherwise will return null
         * @param target
         * @return
         */
        public EnemySubSetNode findEnemy(BaseEnemy target)
        {
            EnemySubSetNode retVal = null;

            if (target != null)
            {
                EnemySubSetNode currentNode = firstNode.getNextNode();
                while (currentNode != null && retVal == null)
                {
                    if (currentNode.data == target)
                    {
                        retVal = currentNode;
                    }
                    currentNode = currentNode.getNextNode();
                }
            }
            return(retVal);
        }
Exemplo n.º 9
0
 private void ByteTarget(BaseEnemy target)
 {
     if (target != null && hostSet != null)
     {
         EnemySoundManager.requestSound(EnemySoundManager.SoundType.CAT_ATTACK);
         if (target.type == InteractableObject.ObjectType.ANGRY)
         {
             ((Ghost)target).explode();
             removeThis();
         }
         else
         {
             target.removeThis();
         }
     }
     if (currentTarget != null)
     {
         currentTarget.removeNode();
         currentTarget = null;
     }
     targetEnemyCollumn = -1;
 }
Exemplo n.º 10
0
 /**
  * Will set the Target of the Byte and will Deduct any points that will need to be Deducted as a result of the byte
  * Will Also Set the Animation to move towards the Byte target within the Fist half of the animation ime
  * @return The super.storedStateChangeObject as the change game state
  */
 private StateChange setByteTarget()
 {
     storedStateChangeObject.setToDefualts();
     bytePos = 0;
     if (currentTarget != null)
     {
         currentTarget.removeNode();
     }
     if (hostSet != null)
     {
         //initializing targtableGhosts
         if (targtableGhosts == null)
         {
             targtableGhosts = new List <BaseEnemy>();
         }
         targtableGhosts.Clear();
         if (targtableGhosts.Capacity < hostSet.getNumberOfCollumns(currentRow))
         {
             targtableGhosts.Capacity = hostSet.getNumberOfCollumns(currentRow);
         }
         //Finding Ghosts
         BaseEnemy target = null;
         for (int loop = 0; loop < hostSet.getNumberOfCollumns(currentRow); loop++)
         {
             target = hostSet.getEnemyAt(currentRow, loop);
             if (target != null && target.isTypeRevealed && (target.type == InteractableObject.ObjectType.ANGRY || target.type == InteractableObject.ObjectType.GHOST))
             {
                 targtableGhosts.Add(target);
             }
         }
         //Choosing Ghost to byte
         if (targtableGhosts.Count == 0)
         {
             targetEnemyCollumn = -1;
             byteTarget         = null;
         }
         //single target
         else if (targtableGhosts.Count == 1)
         {
             byteTarget         = targtableGhosts[0];
             targetEnemyCollumn = byteTarget.currentCollumn;
             //is enemy already targeted
             if (isEnemyAlreadyTargeted(byteTarget))
             {
                 targetEnemyCollumn = -1;
                 byteTarget         = null;
             }
             //targeting enemy
             else
             {
                 currentTarget = targetEnemy(byteTarget);
             }
         }
         //Multiple targets
         else
         {
             byteTarget         = targtableGhosts[((int)(rand.NextDouble() * (targtableGhosts.Count)))];
             targetEnemyCollumn = byteTarget.currentCollumn;
             //is enemy already targeted
             if (isEnemyAlreadyTargeted(byteTarget))
             {
                 targetEnemyCollumn = -1;
                 byteTarget         = null;
             }
             //targeting enemy
             else
             {
                 currentTarget = targetEnemy(byteTarget);
             }
         }
     }
     return(storedStateChangeObject);
 }