Exemple #1
0
        public override void Update(Utility.Key key)
        {
            if(selectbox == null){
                int x = target.x;
                int y = target.y;
                if(key.Up()) y -= 1;
                if(key.Down()) y += 1;
                if(key.Left()) x -= 1;
                if(key.Right()) x += 1;
                if(x != target.x || y != target.y){
                    if(field[x][y] != 1){
                        var cc = CharacterByCoord(x, y);
                        if(cc != null){
                            message.buffer.Add(string.Format("{0} hits {1} !", target.id, cc.id));
                            cc.hp -= target.atk;
                        }else{
                            target.x = x;
                            target.y = y;
                        }

                        foreach(var c in characters){
                            int xnextc = c.x;
                            int ynextc = c.y;
                            if(target.x - c.x != 0) xnextc += (target.x - c.x)/(Math.Abs(target.x - c.x));
                            if(target.y - c.y != 0) ynextc += (target.y - c.y)/(Math.Abs(target.y - c.y));

                            var ccc = CharacterByCoord(xnextc, ynextc);
                            if(ccc != null){
                                message.buffer.Add(string.Format("{0} hits {1} !", c.id, ccc.id));
                                ccc.hp -= c.atk;
                            }else{
                                c.x = xnextc;
                                c.y = ynextc;
                            }
                        }
                    }
                }
                xcamera = target.x*64 - 288;
                ycamera = target.y*64 - 208;

                if(key.X()){
                    selectbox = new UI.SelectBox(352, 240, 256, new string[]{"Save XD", "Back to the Opening", "Exit :("});
                }
            }else{
                selectbox.Update(key);
                if(key.A()){
                    if(selectbox.cursor == 0){
                        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(DungeonData));
                        var fs = new System.IO.FileStream("savedata.xml", System.IO.FileMode.Create);
                        serializer.Serialize(fs, GetSaveData());
                        fs.Close();
                    }else if(selectbox.cursor == 1){
                        sdata.scene_next = new Opening(sdata);
                    }else{
                        sdata.endgame = true;
                    }
                }else if(key.B()){
                    selectbox = null;
                }
            }
        }
Exemple #2
0
 public void Update(Utility.Key key)
 {
     if(key.Up()) cursor = (cursor - 1 + lines.Length)%lines.Length;
     if(key.Down()) cursor = (cursor + 1 + lines.Length)%lines.Length;
 }