Esempio n. 1
0
 private void CreateElement(int slot)
 {
     currElement = Element.ElementBuilder.GetBaseElement(m_Type, m_Level, slot);
     currElement.Position = m_Position;
     //currElement.OnGrab += Element_OnGrab;
     currElement.OnDrop += Element_OnDrop;
 }
Esempio n. 2
0
        public void Button_OnClick(UIButton source)
        {
            if (currElement == null)
                return;

            switch (source.ButtonType)
            {
                case UIButton.Button.clearButton:
                    m_Level.AddSFX(Level.SFXNames.resetElement);
                    currElement.Destroy();
                    break;
                default:
                    return;
            }
            currElement = null;
        }
Esempio n. 3
0
 public void Element_OnCast(Element source)
 {
     int nSatisfied = 0;
     bool bSatisfied = false;
     int nMin = (m_State == State.Dropping ? 4 : 0);
     int nMax = Math.Min(nMin + 4, m_arrCards.Count);
     //check against each card in the bottom row of the queue
     for (int i = nMin; i < nMax; i++)
     {
         if (m_arrCards[i].Satisfied)
             nSatisfied++;
         else if (!bSatisfied && m_arrCards[i].Satisfy(source))
         {
             m_Level.AddSFX(Level.SFXNames.cardActivated);
             m_Level.updateTaskValue(m_arrCards[i].Value);
             nSatisfied++;
             bSatisfied = true;
         }
     }
     //if there are no cards left in the queue, mark task as completed
     if (nSatisfied == m_arrCards.Count)
     {
         m_Level.AddSFX(Level.SFXNames.taskComplete);
         m_Level.TaskFinished();
     }
     else if (nSatisfied == 4)//if we finished a row, tell it to disappear and move the other rows down
     {
         m_Level.updateTaskTime(5000);
         m_Level.AddSFX(Level.SFXNames.rowComplete);
         for (int i = 0; i < m_arrCards.Count; i++)
         {
             if (i < 4)
                 m_arrCards[i].ClearCard();
             else
                 m_arrCards[i].Enable();
         }
         m_State = State.Dropping;
         m_nTimer = 0;
     }
 }
Esempio n. 4
0
        public Card(Element.Type a_Type, Vector2 a_Position, Level a_Level, State a_State)
        {
            m_Type = a_Type;
            m_Position = a_Position;
            m_State = a_State;
            m_Level = a_Level;
            LoadContent(a_Level);
            m_nFadeInTimer = 0;

            if (a_Type <= Element.Type.Earth)
                value =  25;
            else if (a_Type <= Element.Type.Stone)
                value = 50;
            else if (a_Type <= Element.Type.Death)
                value = 75;
            else if (a_Type <= Element.Type.Tree)
                value = 100;
            else if (a_Type <= Element.Type.Hurricane)
                value = 125;
            else
                value = 150;
        }
Esempio n. 5
0
 public void ElementDropped(DraggableItem sender)
 {
     if (active)
     {
         if (currElement == sender)
         {
             Element.Type temp = currElement.ElementType;
             currElement = null;
             Element savedElement = Element.ElementBuilder.GetElement(temp, m_Level, SageGame.gameSelectedIndex);//SLOT
             DroppedIn(savedElement);
             m_Level.remain(savedElement);
         }
         if (sender is Element && new Rectangle((int)m_Position.X, (int)m_Position.Y, m_nWidth, m_nHeight).Intersects(sender.BoundingBox))
             ((Element)sender).RegisterSaveArea(this);
     }
 }
Esempio n. 6
0
 public void ElementBuilt(Element created)
 {
     created.OnDrop += ElementDropped;
 }
Esempio n. 7
0
 public void DroppedIn(Element a_Element)
 {
     if (currElement != null)
     {
         currElement.currHolder = Element.Holder.None;
         currElement.Draggable = false;
     }
     currElement = a_Element;
     //else if (currElement != a_Element)
     //{
     //    currElement = Element.ElementBuilder.GetElement(currElement, a_Element, m_Level);
     //    if (currElement.ElementType == Element.Type.Fizzle)
     //    {
     //        m_Level.AddSFX(Level.SFXNames.fizzle);
     //        currElement.Position = m_Position + new Vector2(m_nWidth / 2, m_nHeight / 2);
     //        currElement = null;
     //    }
     //    else
     //    {
     //        m_Level.AddSFX(Level.SFXNames.combineElement);
     //    }
     //}
     if (currElement != null) {
         currElement.Position = m_Position + new Vector2(10, 10);
     }
     currElement.currHolder = Element.Holder.SaveSlot;
 }
Esempio n. 8
0
            /// <summary>
            /// Returns the appropriate Element object based on the two Elements provided to combine.
            /// the Elements provided will turn to Fizzle types since they should be discarded after
            /// they are used to create another Element.
            /// </summary>
            /// <param name="a_ElementOne"></param>
            /// <param name="a_ElementTwo"></param>
            /// <param name="a_level"></param>
            /// <returns>The resulting element. Fizzle if there is no valid combination.</returns>
            public static Element GetElement(Element a_ElementOne, Element a_ElementTwo, Level a_level, int slot)
            {
                Element.Type TypeA = a_ElementOne.m_Type;
                Element.Type TypeB = a_ElementTwo.m_Type;
                if (TypeA > TypeB)
                {
                    Element.Type temp = TypeB;
                    TypeB = TypeA;
                    TypeA = temp;
                }

                a_ElementOne.Destroy(true);
                a_ElementTwo.Destroy(true);
                Element element = new Element(Map[(int)TypeA, (int)TypeB], a_level, slot);
                element.currHolder = Holder.Board;
                if (GetElementPermission(a_level.Score.Prestige) < element.GetElementTier()) element.Destroy();
                if (OnBuild != null)
                    OnBuild(element);
                return element;
            }
Esempio n. 9
0
 public ElementGenerator(Vector2 a_Position, Level a_Level, Element.Type a_Type)
 {
     m_Level = a_Level;
     m_Position = a_Position;
     m_Type = a_Type;
 }
Esempio n. 10
0
        private static Element.Type[] combine(Element.Type[] a, Element.Type[] b)
        {
            List<Element.Type> c = new List<Element.Type>();
            c.AddRange(a);
            c.AddRange(b);

            return c.ToArray();
        }
Esempio n. 11
0
 public void remain(Element saved)
 {
     saved_e = saved;
     save_rdy = true;
 }
Esempio n. 12
0
 public bool Satisfy(Element a_Element)
 {
     if (m_State == State.Available && a_Element.ElementType == m_Type)
     {
         m_State = State.Activated;
         return true;
     }
     return false;
 }
Esempio n. 13
0
 public Boolean checkifNeededCard(Element e)
 {
     return false;
 }
Esempio n. 14
0
 private static void AddToMap(Element.Type a_ElementOne, Element.Type a_ElementTwo, Element.Type a_ElementResult, Element.Type[,] a_mapElements)
 {
     if (a_ElementOne > a_ElementTwo)
     {
         Element.Type temp = a_ElementTwo;
         a_ElementTwo = a_ElementOne;
         a_ElementOne = temp;
     }
     a_mapElements[(int)a_ElementOne, (int)a_ElementTwo] = a_ElementResult;
 }
Esempio n. 15
0
 public static Element GetElement(Element.Type type, Level level, int slot)
 {
     Element element = new Element(type, level, slot);
     element.currHolder = Holder.Board;
     if (GetElementPermission(level.Score.Prestige) < element.GetElementTier()) element.Destroy();
     if (OnBuild != null)
         OnBuild(element);
     return element;
 }
Esempio n. 16
0
        public void Dispose()
        {
            Element.ElementBuilder.OnBuild -= ElementBuilt;
            m_btnClear.OnClick -= Button_OnClick;

            //if nobody else is connected, clean them up
            m_btnClear.Dispose();
            currElement = null;
            m_Level = null;
        }
Esempio n. 17
0
 public void DroppedIn(Element a_Element, int slot)
 {
     if (currElement == null)
     {
         currElement = a_Element;
     }
     else if (currElement != a_Element)
     {
         currElement = Element.ElementBuilder.GetElement(currElement, a_Element, m_Level, slot);
         if (currElement.ElementType == Element.Type.Fizzle)
         {
             m_Level.AddSFX(Level.SFXNames.fizzle);
             currElement.Position = m_Position + new Vector2(m_nWidth / 2, m_nHeight / 2);
             currElement = null;
         }
         else
         {
             m_Level.AddSFX(Level.SFXNames.combineElement);
         }
     }
     if (currElement != null)
         currElement.Position = m_center;
 }
Esempio n. 18
0
 public TaskLevel(Element.Type[] Elements, int NumberElementsMin, int NumberElementsMax)
 {
     this.Elements = Elements;
     this.NumberElementsMin = NumberElementsMin;
     this.NumberElementsMax = NumberElementsMax;
 }
Esempio n. 19
0
 public void ElementDropped(DraggableItem sender)
 {
     if (currElement == sender)
         currElement = null;
     if (sender is Element && new Rectangle((int)m_Position.X, (int)m_Position.Y, m_nWidth, m_nHeight).Intersects(sender.BoundingBox))
         ((Element)sender).RegisterDropArea(this);
 }
Esempio n. 20
0
 public void Dispose()
 {
     m_Level = null;
     currElement.OnDrop -= Element_OnDrop;
     currElement = null;
 }
Esempio n. 21
0
 public void Element_OnSpamDrop(Element sender)
 {
     if (currElement == null)
         sender.RegisterDropArea(this);
 }
Esempio n. 22
0
 public void Dispose()
 {
     Element.ElementBuilder.OnBuild -= ElementBuilt;
     m_btnCast.OnClick -= Button_OnClick;
     m_btnClear.OnClick -= Button_OnClick;
     Element.OnSpamDrop -= Element_OnSpamDrop;
     m_btnCastAll.OnClick -= Button_OnClick;
     m_btnClearAll.OnClick -= Button_OnClick;
     //if nobody else is connected, clean them up
     if (m_btnClearAll.OnClick == null)
     {
         m_btnClearAll = null;
         m_btnCastAll = null;
     }
     m_btnClear.Dispose();
     m_btnCast.Dispose();
     currElement = null;
     m_Level = null;
 }
Esempio n. 23
0
 /// <summary>
 /// This will only return Fire, Water, Wind, and Earth elements, everything else
 /// needs to go through GetElement(...) to ensure that proper combining is adhered to
 /// </summary>
 /// <param name="a_Type"></param>
 /// <param name="a_Level"></param>
 /// <returns></returns>
 public static Element GetBaseElement(Element.Type a_Type, Level a_Level, int slot)
 {
     switch (a_Type)
     {
         case Element.Type.Water:
         case Element.Type.Wind:
         case Element.Type.Fire:
         case Element.Type.Earth:
             Element element = new Element(a_Type, a_Level, slot);
             if (OnBuild != null)
                 OnBuild(element);
             return element;
         default:
             return null;
     }
 }