Hi!
I'm trying to do something kinda wacky and can't seem to get it working right ( if it's even possible ). Any ideas on how to do this would be great!
Ok, I have a base class name RKObject ( only included the important stuff ):
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Reflection;
namespace RKLight
{
public class RKObject : Control
{
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// ENUMERATIONS
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
public enum RKObjectAnims
{
NUM_RK_OBJECT_ANIMS,
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// MEMBER VARIABLES
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// List of animations associated with this object ( timelines )
protected List<string> anims = new List<string>();
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// METHODS
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// RKObject()
//
// Constructor.
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
public RKObject()
{
RKObjectAnims curAnimEnum;
// Setup animations
for (int i = 0; i < (int)RKObjectAnims.NUM_RK_OBJECT_ANIMS; i++)
{
curAnimEnum = (RKObjectAnims)i;
anims.Add(curAnimEnum.ToString());
}
}
}
}
And a derived class named Test ( again, only included the important stuff ):
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RKLight;
namespace Test
{
public class Test : RKObject
{
new public enum RKObjectAnims
{
RectFade,
RectRot,
NUM_RK_OBJECT_ANIMS,
}
public void Tick()
{
if (Input.Get().KeyPressedNew(Key.LEFT))
{
PlayAnim((int)RKObjectAnims.RectFade);
}
if (Input.Get().KeyPressedNew(Key.RIGHT))
{
PlayAnim((int)RKObjectAnims.RectRot);
}
}
}
}
This of course doesn't work, but the basic idea is this:
The RKObjectAnims enumeration is defined in both the base class and my derived class. Since, I want my animation enumerations to correspond to their anim names ( strings ) without having to keep two tables, I initialize the anims list with the enumerations using the "ToString()" method.
This would be great, except that I don't want to have to initialize it in every derived class: I want the base class to automatically do it for me. However, the base class only knows about it's RKObjectAnims enums, not my derived class version.
What I would LOVE to happen is that I simply add an entry to the derived class enumeration ( in Test ) and the anims string list gets filled in automatically in the base class with that enum's ToString() version. Then, all I need to do is use the derived class enumeration index to play an animation ( seen in the Tick of Test class ).
If anyone has any way for me to do this, I would be so happy :)
Thanks in advance!