Inheritance: MonoBehaviour
Example #1
0
        internal NormalizedFunction(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr));
            }

            var functionType = typeof(TFunction);
            var svmFunction  = functionType.GetGenericTypeDefinition();

            if (!FunctionTypesRepository.Types.TryGetValue(svmFunction, out var svmFunctionType))
            {
                throw new ArgumentException();
            }

            var kernelType = functionType.GenericTypeArguments[1].GetGenericTypeDefinition();

            if (!KernelTypesRepository.KernelTypes.TryGetValue(kernelType, out var svmKernelType))
            {
                throw new ArgumentException();
            }

            var elementType = functionType.GenericTypeArguments[0];

            if (!KernelTypesRepository.ElementTypes.TryGetValue(elementType, out var sampleType))
            {
                throw new ArgumentException();
            }

            this._Parameter       = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            this._SvmFunctionType = svmFunctionType;
            this._Imp             = this.CreateImp(sampleType.ToNativeMatrixElementType());

            this.NativePtr = ptr;
        }
Example #2
0
        static void Main()
        {
            string?name = null;
            //   var myName = name!.ToString(); // Null Forgiving Operator

            //int i = int.MaxValue;

            //    int k = checked(i + 1);
            //    Console.WriteLine(k);

            //IDisplay impObj = new Imp();
            //impObj.Print();
            //impObj.Display();

            Imp impObj = new Imp();

            //impObj.Calculate(5, 6);

            DateTime date = DateTime.Now.Date;

            for (int i = 15; i <= 135; i = i + 15)
            {
                Console.WriteLine(date.AddMinutes(i).ToString("{hh:mm}"));
            }

            // Console.WriteLine(DateTime.Now.Date);
        }
Example #3
0
        public NormalizedFunction()
        {
            var functionType = typeof(TFunction);
            var svmFunction  = functionType.GetGenericTypeDefinition();

            if (!FunctionTypesRepository.Types.TryGetValue(svmFunction, out var svmFunctionType))
            {
                throw new ArgumentException();
            }

            var kernelType = functionType.GenericTypeArguments[1].GetGenericTypeDefinition();

            if (!KernelTypesRepository.KernelTypes.TryGetValue(kernelType, out var svmKernelType))
            {
                throw new ArgumentException();
            }

            var elementType = functionType.GenericTypeArguments[0];

            if (!KernelTypesRepository.ElementTypes.TryGetValue(elementType, out var sampleType))
            {
                throw new ArgumentException();
            }

            this._Parameter       = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            this._SvmFunctionType = svmFunctionType;
            this._Imp             = this.CreateImp(sampleType.ToNativeMatrixElementType());
            this.NativePtr        = NativeMethods.normalized_function_new(this._Parameter.KernelType.ToNativeKernelType(),
                                                                          this._Parameter.SampleType.ToNativeMatrixElementType(),
                                                                          this._Parameter.TemplateRows,
                                                                          this._Parameter.TemplateColumns,
                                                                          svmFunctionType);
        }
Example #4
0
        public WndImp(Imp imp, DwarfToken tokens)
        {
            _imp    = imp;
            _tokens = tokens;
            var titlebar = new IconTitle();

            titlebar.Icon(new ItemSprite(tokens.Image, null));
            titlebar.Label(Utils.Capitalize(tokens.Name));
            titlebar.SetRect(0, 0, WIDTH, 0);
            Add(titlebar);

            BitmapTextMultiline message = PixelScene.CreateMultiline(TxtMessage, 6);

            message.MaxWidth = WIDTH;
            message.Measure();
            message.Y = titlebar.Bottom() + Gap;
            Add(message);

            var btnReward = new RedButton(TxtReward);

            btnReward.ClickAction = RewardClickAction;
            btnReward.SetRect(0, message.Y + message.Height + Gap, WIDTH, BtnHeight);
            Add(btnReward);

            Resize(WIDTH, (int)btnReward.Bottom());
        }
Example #5
0
            protected override void OnTick()
            {
                if (m_Item.Deleted)
                {
                    return;
                }

                Mobile spawn;

                switch (Utility.Random(8))
                {
                default:
                case 0: spawn = new ElderGazer(); break;

                case 1: spawn = new Imp(); break;

                case 2: spawn = new OrcBrute(); break;

                case 3: spawn = new Phoenix(); break;

                case 4: spawn = new Quagmire(); break;

                case 5: spawn = new WhippingVine(); break;

                case 6: spawn = new Drake(); break;

                case 7: spawn = new VorpalBunny(); break;
                }

                spawn.MoveToWorld(m_Item.Location, m_Item.Map);

                m_Item.Delete();
            }
Example #6
0
 protected void initImp()
 {
     PathCell pc = _pathCells[0];
     _imp = new Imp(pc.X, pc.Y);
     _imp.Position = 0;
     MapCanvas.Children.Add(_imp);
 }
Example #7
0
 internal static void UpdateKeyBindings()
 {
     if (s_sharedInstance != null)
     {
         Imp.UpdateKeyBindings();
     }
 }
Example #8
0
    protected override void OnAwake()
    {
        bomb               = Resources.Load <Bomb>("Objects/Bomb");
        cardReset          = Resources.Load <CardReset>("Objects/CardReset");
        changeCardPosition = Resources.Load <ChangeCardPosition>("Objects/ChangeCardPosition");
        weapon             = Resources.Load <Weapon>("Objects/Weapon");
        flameThrower       = Resources.Load <FlameThrower>("Objects/Flame");


        //Trap
        thorn = Resources.Load <Thorn>(PATH_TRAP + "Thorn");
        //Trap


        //Coin
        goldCoin = Resources.Load <Coin>(PATH_COIN + "GoldCoin");
        //Coin


        //Monster
        ghost = Resources.Load <Monster>(PATH_MONSTER + "Ghost");
        slime = Resources.Load <Slime>(PATH_MONSTER + "Slime");
        imp   = Resources.Load <Imp>(PATH_MONSTER + "Imp");
        //Monster


        //Potion
        blackPotion  = Resources.Load <BlackPotion>(PATH_POTION + "BlackPotion");
        bluePotion   = Resources.Load <BluePotion>(PATH_POTION + "BluePotion");
        pinkPotion   = Resources.Load <PinkPotion>(PATH_POTION + "PinkPotion");
        purplePotion = Resources.Load <PurplePotion>(PATH_POTION + "PurplePotion");
        redPotion    = Resources.Load <RedPotion>(PATH_POTION + "RedPotion");
        yellowPotion = Resources.Load <YellowPotion>(PATH_POTION + "Yellowpotion");
        //Potion
    }
Example #9
0
        public SvmCTrainer()
        {
            var kernelType = typeof(TKernel).GetGenericTypeDefinition();

            if (!KernelTypesRepository.KernelTypes.TryGetValue(kernelType, out var svmKernelType))
            {
                throw new ArgumentException();
            }
            var elementType = typeof(TKernel).GenericTypeArguments[0];

            if (!KernelTypesRepository.ElementTypes.TryGetValue(elementType, out var sampleType))
            {
                throw new ArgumentException();
            }

            this._Parameter = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            var error = NativeMethods.svm_c_trainer_new(svmKernelType.ToNativeKernelType(),
                                                        sampleType.ToNativeMatrixElementType(),
                                                        out var ret);

            switch (error)
            {
            case NativeMethods.ErrorType.MatrixElementTypeNotSupport:
                throw new ArgumentException($"{this._Parameter.SampleType} is not supported.");

            case NativeMethods.ErrorType.SvmKernelNotSupport:
                throw new ArgumentException($"{this._Parameter.KernelType} is not supported.");
            }

            this._Imp      = CreateImp(this._Parameter);
            this.NativePtr = ret;
        }
Example #10
0
 public void Redo()
 {
     if (Imp.Redo())
     {
         Modified = true;
         OnTextChanged(EventArgs.Empty);
     }
 }
Example #11
0
 public void Undo()
 {
     // TODO
     if (Imp.Undo())
     {
         Modified = true;
         OnTextChanged(EventArgs.Empty);
     }
 }
    public static void Assignment()
    {
        Imp imp1 = new Imp();

        // imp1.sameMethod(); This is impossible.
        I1 i1 = imp1;

        i1.sameMethod();    // Now it's possible.
    }
Example #13
0
 public void remove(Imp imp)
 {
     if (imp.CurrentJob != null)
     {
         jobsWaiting.Enqueue(imp.CurrentJob);
         jobsInProgress.Remove(imp.CurrentJob);
     }
     getHexagonAt(imp.Position).Obj = null;
     impList.Remove(imp);
 }
Example #14
0
 public void move(Imp imp)
 {
     if (imp.Path != null && imp.Path.Count != 0 && getHexagonAt(imp.Path.Peek()).Imps.Count < 6)
     {
         getHexagonAt(imp.Position).Imps.Remove(imp);
         imp.Position       = imp.Path.Pop();
         imp.CurrentHexagon = getHexagonAt(imp.Position);
         getHexagonAt(imp.Position).Imps.Add(imp);;
     }
 }
Example #15
0
    public void ReturnImpMonster(Imp card)
    {
        if (card.gameObject.activeSelf)
        {
            card.gameObject.SetActive(false);
        }

        card.transform.SetParent(_tr_Monster_Imp);
        _stack_Monster_Imp.Push(card);
    }
Example #16
0
    private void MakeImpMonster(int count)
    {
        for (int i = 0; i < count; i++)
        {
            Imp newMonster = Instantiate(DataManager.instance.imp);
            newMonster.gameObject.SetActive(false);
            newMonster.transform.SetParent(_tr_Monster_Slime);

            _stack_Monster_Imp.Push(newMonster);
        }
    }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RunningStats{TTKernel}"/> class.
        /// </summary>
        public VectorNormalizer()
            : base(NormalizerType.Vector)
        {
            if (!VectorNormalizerElementTypesRepository.Types.TryGetValue(typeof(TElement), out var type))
            {
                throw new NotSupportedException($"{typeof(TElement).Name} does not support");
            }

            this._ElementType = type.ToNativeMatrixElementType();
            this._Imp         = this.CreateImp(type);
            this.NativePtr    = NativeMethods.vector_normalizer_new(this._ElementType);
        }
Example #18
0
        public static void Register(Type T)
        {
            foreach (var Imp in AllImporters)
            {
                if (Imp.GetType() == T)
                {
                    throw new Exception("Importer already registered: " + T.ToString());
                }
            }

            AllImporters.Add((Importer)Activator.CreateInstance(T));
        }
Example #19
0
        public async Task ReloadDataFailed_Test()
        {
            // Arrange
            _mockIGetBreedByIdUseCase.Setup(x => x.Execute(It.IsAny <IGetBreedByIdUseCase.Param>()))
            .ThrowsAsync(new Exception());

            // Act
            await Imp.LoadData();

            Assert.False(Imp.IsBusy);
            Assert.True(Imp.LoadingError);
        }
Example #20
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
     imp = FindObjectOfType <Imp>();
 }
Example #21
0
 private void CheckForImp()
 {
     //Check if there is an imp in the workingImpList at the location of this worker index
     if (m_workingImpList.Count < m_workerIndex + 1)
     {
         m_workingImpList.Add(null);
     }
     else if (m_workingImpList.List[m_workerIndex])
     {
         m_hasImp = true;
         m_impObj = m_workingImpList.List[m_workerIndex].GetComponent <Imp>();
     }
 }
        public bool Act(Monster monster, CommandSystem commandSystem)
        {
            DungeonMap map = RogueGame.DungeonMap;

            // Ooze only splits when wounded
            if (monster.Health >= monster.MaxHealth)
            {
                return(false);
            }

            int halfHealth = monster.MaxHealth / 2;

            if (halfHealth <= 0)
            {
                // Health would be too low so bail out
                return(false);
            }

            Cell cell = FindClosestUnoccupiedCell(map, monster.X, monster.Y);

            if (cell == null)
            {
                // No empty cells so bail out
                return(false);
            }

            // Make a new ooze with half the health of the old one
            Imp newOoze = Monster.Clone(monster) as Imp;

            if (newOoze != null)
            {
                newOoze.TurnsAlerted = 1;
                newOoze.X            = cell.X;
                newOoze.Y            = cell.Y;
                newOoze.MaxHealth    = halfHealth;
                newOoze.Health       = halfHealth;
                map.AddMonster(newOoze);
                RogueGame.MessageLog.Add($"{monster.Name} splits itself in two");
            }
            else
            {
                // Not an ooze so bail out
                return(false);
            }

            // Halve the original ooze's health too
            monster.MaxHealth = halfHealth;
            monster.Health    = halfHealth;

            return(true);
        }
Example #23
0
        public static Importer <T> Get <T>(string FilePath)
        {
            IEnumerable <Importer <T> > Importers = GetAll <T>();

            foreach (var Imp in Importers)
            {
                if (Imp.CanLoad(FilePath))
                {
                    return(Imp);
                }
            }

            throw new Exception("Could not find importer for \"" + FilePath + "\"");
        }
Example #24
0
        public SvmCTrainer(TKernel kernelBase,
                           TScalar c)
        {
            if (kernelBase == null)
            {
                throw new ArgumentNullException(nameof(kernelBase));
            }

            kernelBase.ThrowIfDisposed();

            this._Parameter = new KernelBaseParameter(kernelBase.KernelType, kernelBase.SampleType, 0, 0);
            this._Imp       = CreateImp(this._Parameter);
            this.NativePtr  = this._Imp.Create(kernelBase.NativePtr, c);
        }
Example #25
0
        internal ReducedDecisionFunctionTrainer2(IntPtr ptr,
                                                 bool isEnabledDispose = true) :
            base(isEnabledDispose)
        {
            TrainerHelper.GetTypes <TScalar, TTrainer>(out _,
                                                       out var svmTrainerType,
                                                       out var svmKernelType,
                                                       out var sampleType);

            this._Parameter      = new KernelBaseParameter(svmKernelType, sampleType, 0, 0);
            this._SvmTrainerType = svmTrainerType;
            this._Imp            = CreateImp(this._Parameter);

            this.NativePtr = ptr;
        }
Example #26
0
        static private void randomwalk(Imp imp, Environment.Map map)
        {
            //random determination of next step
            int random = (int)rand.Next(6);

            if (map.getHexagonAt(map.getHexagonAt(imp.Position).Neighbors[random]).Obj == null ||
                map.getHexagonAt(map.getHexagonAt(imp.Position).Neighbors[random]).Obj.getThingTyp() != Vars_Func.ThingTyp.Wall)
            {
                if (imp.Path == null)
                {
                    imp.Path = new Stack <Vector2>();
                }
                imp.Path.Push(map.getHexagonAt(imp.Position).Neighbors[random]);
            }
        }
Example #27
0
        public void SpawnEnemy()
        {
            ResetAllVertices();
            Imp imp = new Imp(waveCount)
            {
                pos  = startTile.pos,
                path = Path.GetPath(startTile, endTile)
            };

            Instance.enemies.Add(imp);
            foreach (Tower t in towers)
            {
                t.nearbyEnemies.Add(imp);
            }
        }
Example #28
0
        //////////////////////////////////////////////////////////////////////////////

        #region static Access

        public static bool ExecCommand(string commandLine, bool manual = false)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException("commandLine");
            }

            if (s_sharedInstance == null)
            {
                CLog.e("Can't execute command: app is not initialized");
                return(false);
            }

            return(Imp.ExecCommand(commandLine, manual));
        }
Example #29
0
        public void AppendText(string text)
        {
            if (String.IsNullOrEmpty(text))
            {
                return;
            }

            Imp.AppendText(text);

            //MoveCaret(CaretDirection.CtrlEnd);
            //SetSelectionToCaret(true);
            //ScrollToCaret();

            Modified = false;
            OnTextChanged(EventArgs.Empty);
        }
Example #30
0
        public static Monster CreateMonster(int level, Point location)
        {
            Pool <Monster> monsterPool = new Pool <Monster>();

            monsterPool.Add(Kobold.Create(level), 25);
            monsterPool.Add(Imp.Create(level), 25);
            monsterPool.Add(Goblin.Create(level), 50);
            monsterPool.Add(Werewolf.Create(level), 50);

            Monster monster = monsterPool.Get();

            monster.X = location.X;
            monster.Y = location.Y;

            return(monster);
        }
        public LostSoul(Imp _parent, float _damage, Vector2 _direction, float _speed, TimeSpan _timeToLive, Vector2 _pos, Vector2 _dims, string _path = "Sprites\\Lost Soul") : base(_path, _pos, _dims)
        {
            damage    = _damage;
            parent    = _parent;
            direction = _direction;
            direction.Normalize();
            speed = _speed;

            if (direction.X > 0)
            {
                flipSprite = true;
            }

            rotationSprite = (-1 * direction.X + 0 * _direction.Y) / (new Vector2(-1, 0).Length() * _direction.Length());

            timeCreated = DateTime.Now;
            timeToLive  = _timeToLive;
        }
	void OnCollisionEnter2D(Collision2D aCollision)
	{
		if (!m_HasImp)
		{
			if (aCollision.gameObject.GetComponent<Imp>() != null)
			{
				currentImpInHand = aCollision.gameObject.GetComponent<Imp>();
				currentImpInHand.GetComponent<Imp>().enabled = false;
				aCollision.transform.position = m_RightImpSpot.position;
				aCollision.transform.SetParent(transform);
				m_HasImp = true;
			}
		}
	}
	void FireImp()
	{
		if (currentImpInHand != null)
		{
			
			currentImpInHand.transform.SetParent(null);
			currentImpInHand.GetComponent<Imp>().enabled = true;
			currentImpInHand = null;
			m_HasImp = false;
		}
	}
	void OnTriggerEnter2D(Collider2D aCollider2D)
	{
		if (currentImpInHand != null)
		{
			if (aCollider2D.CompareTag("Fire"))
			{
				//Collided with the fire
				Game_Controller.AddToDemonBar(10);
				Destroy(currentImpInHand.gameObject);
				currentImpInHand = null;
				m_HasImp = false;
			}
		}
	}
	// Use this for initialization
	void Start () {
		animator = GetComponent<Animator> ();
		imp = GetComponentInParent<Imp> ();
		attack = imp.GetComponent<BasicMelee> ();
		attackString = "Spell";
	}