Changeset 6272 for 2014/30


Ignore:
Timestamp:
2015-06-24 15:14:15 (8 years ago)
Author:
anlakane
Message:
 
Location:
2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/Attack_to_Agora.cs

    r6249 r6272  
    2424    PlatformCharacter taistelija; 
    2525 
    26     int kenttaNro = 1; 
     26    int kenttaNro = 2; 
    2727 
    2828    /// <summary> 
    2929    /// Viimeisen pelissä olevan kentän indeksi. 
    3030    /// </summary> 
    31     const int VIIMEINEN_KENTTA = 9; 
     31    const int VIIMEINEN_KENTTA = 15; 
    3232 
    3333    public override void Begin() 
     
    192192    } 
    193193 
     194    void LuoChromaCase() 
     195    { 
     196        Mouse.IsCursorVisible = true; 
     197 
     198        List<GameObject> pItems = new List<GameObject>(); 
     199 
     200        for (int i = 0; i < 40; i++) 
     201        { 
     202            GameObject obj = new GameObject(50, 50); 
     203            obj.Color = RandomGen.NextColor(); 
     204            obj.Tag = 50.0; 
     205            pItems.Add(obj); 
     206        } 
     207 
     208        GameObject cCaseDialog = new GameObject(LoadImage("laatikko_opening")); // koko debug 
     209        Add(cCaseDialog); 
     210 
     211        Mouse.ListenOn(cCaseDialog, MouseButton.Left, ButtonState.Pressed, delegate 
     212        { 
     213            cCaseDialog.Destroy(); 
     214 
     215            GameObject cCaseFront = new GameObject(200.0, 200.0); 
     216            cCaseFront.Color = new Color(0, 64, 0, 32); 
     217 
     218            ChromaCase cCase = new ChromaCase(pItems, cCaseFront, null, 20); 
     219            cCase.Add(Vector.Zero, 2); 
     220            cCase.ItemReceived += GotItemFromCase; 
     221            cCase.Start(); 
     222 
     223        }, null); 
     224    } 
     225 
     226    void GotItemFromCase(GameObject o) 
     227    { 
     228         
     229    } 
     230 
    194231    /// <summary> 
    195232    /// Asetetaan pelaajalle ohjaimet. 
     
    201238        Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaYlos, null, taistelija); 
    202239        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     240 
     241#if DEBUG 
     242        Keyboard.Listen(Key.C, ButtonState.Pressed, LuoChromaCase, null); 
     243#endif 
    203244    } 
    204245 
  • 2014/30/MitjaK/Attack to Agora/Attack to Agora/Attack to Agora/Attack to Agora/ChromaCase.cs

    r6252 r6272  
    1010    private Vector ShownItemPosition = Vector.Zero; 
    1111    private int CurrentItem = 0; 
     12    public int Items; 
    1213 
    1314    private List<GameObject> PossibleItems = new List<GameObject>(); 
     
    1819    public Vector Position = Vector.Zero; 
    1920 
    20     public const double START_SPEED = 0.1; 
    21     public const double STOP_SPEED = 2.0; 
     21    public const double START_SPEED = 0.02; 
     22    public const double STOP_SPEED = 1.0; 
    2223    private Timer changeTimer = new Timer(); 
    2324 
     
    3435    /// <param name="possibleItems"></param> 
    3536    /// <param name="finalItem"></param> 
    36     public ChromaCase(List<GameObject> possibleItems, GameObject finalItem) 
     37    public ChromaCase(List<GameObject> possibleItems, GameObject front, GameObject finalItem, int items) 
    3738    { 
    3839        this.PossibleItems.AddRange(possibleItems); 
    3940        if (finalItem != null) 
    4041            FinalItem = finalItem; 
     42 
     43        this.OpeningScreenFront = front; 
     44        this.Items = items; 
    4145    } 
    4246 
     
    6165    public void Start() 
    6266    { 
     67        GenerateItemList(Items); 
     68 
    6369        if (ShownItems.Count == 0) 
    6470            return; 
    65  
    66         double speedIncrease = (STOP_SPEED - START_SPEED) / ShownItems.Count; 
     71        // y == startSpeed 
     72        // x == speedIncrease 
     73        // n == shownItems.Count 
     74        // z == stopSpeed 
     75        // solve x y*x^n=z => x = (z / y) ^ (1 / n) 
     76        double speedIncrease = Math.Pow((STOP_SPEED / START_SPEED), (1.0 / ShownItems.Count)); 
    6777 
    6878        changeTimer.Interval = START_SPEED; 
    69         changeTimer.Timeout += delegate { ChangeItem(); }; 
    7079        changeTimer.Timeout += delegate 
    7180        { 
    72             changeTimer.Interval += speedIncrease; 
    73             if (changeTimer.Interval >= STOP_SPEED) 
     81            Game.Instance.MessageDisplay.Add("Item " + CurrentItem.ToString() + ", delay " + changeTimer.Interval); 
     82            changeTimer.Interval *= speedIncrease; 
     83            if (CurrentItem == ShownItems.Count - 1) 
    7484            { 
    7585                changeTimer.Timeout += delegate 
     
    8090                }; 
    8191            } 
     92            else ChangeItem();  
    8293        }; 
    8394        changeTimer.Start(); 
    8495 
    8596        // eka esine näkyville 
    86         ChangeItem(); 
     97        ChangeItem(false); 
    8798    } 
    8899 
    89100    private void ChangeItem(bool destroyOld = true) 
    90101    { 
     102        if (CurrentItem >= ShownItems.Count - 1) 
     103            return; 
     104 
    91105        if (destroyOld) 
    92106        { 
    93             ShownItems[CurrentItem].Destroy(); 
     107            Game.Instance.Remove(ShownItems[CurrentItem]); 
    94108            CurrentItem++; 
    95109        } 
Note: See TracChangeset for help on using the changeset viewer.