Example #1
0
 protected override void Install(Castle.Windsor.IWindsorContainer container)
 {
   container.Register(Classes.FromThisAssembly()
     .BasedOn(typeof (Task))
     .WithService.Self()
     .LifestyleTransient());
 }
        /// <inheritdoc />
        public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, Castle.Core.ComponentModel model, DependencyModel dependency)
        {
            if (dependency.TargetType == null)
            {
                return false;
            }

            Type genericArgument = null;
            if ((dependency.TargetType.IsGenericType) && (dependency.TargetType.GetGenericTypeDefinition() == typeof(IEnumerable<>)))
            {
                genericArgument = dependency.TargetType.GetGenericArguments()[0];
            }
            else
            {
                dependency.TargetType.GetInterfaces().Any(implemented => (implemented.IsGenericType) && (implemented.GetGenericTypeDefinition() == typeof(IEnumerable<>)) &&
                    ((genericArgument = implemented.GetGenericArguments()[0]) != null));
            }

            if ((genericArgument == null) || (!_kernel.HasComponent(genericArgument)))
            {
                return false;
            }

            return true;
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
        direction = Random.Range(0,2);
        droppedBomb = true;
        enemy = this.GetComponent<Rigidbody2D>();
        enemyPosition = enemy.transform.position;
        animations = this.GetComponent<Animator>();
        healthdecrease = GameObject.FindGameObjectWithTag("Castle").GetComponent<Castle>();
        rightToLeft = new Vector3(1,1,1);
        leftToRight = new Vector3(-1,1,1);
        doNotMove = false;

        this.GetComponent<AudioSource>().clip = myclip;

        if (direction == 0)
        {
            tempVar = new Vector3 (9f, 0f, 0f);
            enemy.transform.position = tempVar;
        }
        else
        {
            tempVar = new Vector3 (9f, 0f, 0f);
            enemy.transform.position = -tempVar;
        }
    }
Example #4
0
 public void Init(IKernel kernel, Castle.Core.Configuration.IConfiguration facilityConfig)
 {
     InterceptorFactory.Create = new InterceptorFactory.CreateInterceptor(delegate()
     {
         return new AuditInterceptor(kernel);
     });
 }
Example #5
0
 private static void Kernel_ComponentRegistered(string key, Castle.MicroKernel.IHandler handler)
 {
     if (typeof(IApplicationService).IsAssignableFrom(handler.ComponentModel.Implementation))
     {
         handler.ComponentModel.Interceptors.Add(new InterceptorReference(typeof(ValidationInterceptor)));
     }
 }
		public void Init(IKernel kernel, Castle.Core.Configuration.IConfiguration facilityConfig)
		{
			Assert.IsNotNull(kernel);
			Assert.IsNotNull(facilityConfig);

			Initialized = true;
		}
Example #7
0
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(
         Component.For<IApplicationIssueUnitOfWork>()
                  .ImplementedBy<ApplicationIssueUnitOfWork>()
                  .LifestyleTransient());
 }
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(
         Component.For<IPolicyViolationHandler>()
                  .LifeStyle.Transient);
     container.ResolveAll<IPolicyViolationHandler>();
 }
Example #9
0
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.MVC4"));
     xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.FileSystemPages"));
     xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("xrc.Markdown"));
     xrc.XrcWindsor.InstallExtension(container, System.Reflection.Assembly.Load("DemoWebSite.Lib"));
 }
 public CreatePositionData(List<PiecePosition> pieces,
     Players player_to_move,
     Castle white_castling_options,
     Castle black_castling_options,
     int? capture_en_passant_column,
     ushort fullmove_number,
     ushort halfmove_clock)
 {
     if (pieces == null)
     {
         throw new ArgumentNullException();
     }
     if (capture_en_passant_column.HasValue
         && (capture_en_passant_column < Chessboard.COLUMN_MIN
         || capture_en_passant_column > Chessboard.COLUMN_MAX))
     {
         throw new ArgumentOutOfRangeException();
     }
     m_pieces = pieces;
     m_player_to_move = player_to_move;
     m_white_castling_options = white_castling_options;
     m_black_castling_options = black_castling_options;
     m_capture_en_passant_column = capture_en_passant_column;
     m_fullmove_number = fullmove_number;
     m_halfmove_clock = halfmove_clock;
 }
 public EnemyAttribute(Enemy enemyActor, ContentManager content, Castle castle)
     : base(content)
 {
     randomNumberGenerator = new Random();
     this.mEnemyActor = enemyActor;
     this.mCastle = castle;
 }
		public void NotifyBlogRemoved(Castle.Applications.MindDump.Model.Blog blog)
		{
			foreach(IMindDumpEventSubscriber subs in _subscribers)
			{
				subs.OnBlogRemoved(blog);
			}
		}
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(AllTypes.FromThisAssembly()
                                .Where(Component.IsInSameNamespaceAs<ICurrentSiteAccesor>())
                                .WithService.DefaultInterface()
                                .Configure(c => c.LifeStyle.Transient));
 }
Example #14
0
		public InvocationComposite(IMethodInterceptor[] interceptors,
								   Castle.Core.Interceptor.IInvocation innerInvocation, object[] arguments)
		{
			_interceptors = interceptors;
			_innerInvocation = innerInvocation;
			_arguments = arguments;
		}
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(
       Classes.FromThisAssembly()
       .BasedOn(typeof(System.Web.Mvc.ControllerBase))
       .LifestyleTransient());
 }
 public void Execute(Castle.Windsor.IWindsorContainer container)
 {
     ////Bind default binder to Choice extended default model binder. By this extension, model binder now
     ////supports property binder extension, instead of in parameter of action of controller.
     ModelBinders.Binders.DefaultBinder = new ExtendedDefaultModelBinder();
     ModelBinders.Binders.Add(typeof(TypedObject), new TypedObjectBinder());
 }
 public void Install(IWindsorContainer container, Castle.MicroKernel.IConfigurationStore store)
 {
     container
         .Register(Component.For<IPostService>()
                   	.ImplementedBy<PostService>())
         .Register(Component.For<IMailService>()
                   	.ImplementedBy<MailService>())
         .Register(Component.For<IFriendlyUrlGenerator>()
                   	.ImplementedBy<FriendlyUrlGenerator>())
         .Register(AllTypes.Of(typeof (IValidatorBase<>))
                   	.FromAssemblyNamed("BlogSharp.Model")
                   	.WithService.FromInterface(typeof (IValidatorBase<>))
                   	.Configure(x => x.LifeStyle.Transient))
         .AddFacility<ControllerRegisterFacility>()
         .Register(AllTypes.Of<IController>()
                   	.FromAssemblyNamed("BlogSharp.Web").Configure(x => x.LifeStyle.Transient))
         .Register(Component.For<IExtendedControllerFactory>()
                   	.ImplementedBy<WindsorControllerFactory>())
         .Register(AllTypes.Of<IStartupInstaller>()
                   	.FromAssemblyNamed("BlogSharp.Core.Impl")
                   	.WithService.FirstInterface())
         .Register(AllTypes.Of<IHttpModule>()
                   	.FromAssemblyNamed("BlogSharp.Core.Impl"))
         .Register(Component.For<BlogContextProvider>()
                   	.ImplementedBy<WebBlogContextProvider>());
 }
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            container.Register(Component.For<LastTasksByUserPresenter>()
                                        .Named("InnerLastTasksByUserPresenter")
                                        .LifeStyle.Transient);

            container.Register(Component.For<ILastTasksByUserPresenter>()
                                        .ImplementedBy<LastTasksByUserPresenterWithScope>()
                                        .ServiceOverrides(ServiceOverride.ForKey<ILastTasksByUserPresenter>().Eq("InnerLastTasksByUserPresenter"))
                                        .LifeStyle.Transient);

            container.Register(AllTypes.FromThisAssembly()
                .Where(Component.IsInSameNamespaceAs<IBlogsFromDatabasePresenter>())
                .WithService.DefaultInterface()
                .Configure(c => c.LifeStyle.Transient));

            //container.Register(AllTypes.FromThisAssembly()
            //    .Where(Component.IsInSameNamespaceAs<ILastTasksByUserPresenter>())
            //    .WithService.DefaultInterface()
            //    .Configure(c => c.LifeStyle.Transient));

            container.Register(AllTypes.FromThisAssembly()
                .Where(Component.IsInSameNamespaceAs<ILastTasksByUserQuery>())
                .WithService.DefaultInterface()
                .Configure(c => c.LifeStyle.Transient));

            container.Register(AllTypes.FromThisAssembly()
                .Where(Component.IsInSameNamespaceAs<IAddPostCommand>())
                .WithService.DefaultInterface()
                .Configure(c => c.LifeStyle.Transient));
        }
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(Classes.FromAssembly(typeof(eCommerce.ApplicationLayer.Customers.ICustomerService).Assembly)
         .Where(x => !x.IsInterface && !x.IsAbstract && !x.Name.EndsWith("Dto") && x.Namespace.Contains("ApplicationLayer"))
         .WithService.DefaultInterfaces()
         .Configure(c => c.LifestyleTransient()));
 }
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register
         (
                 new NhibernateAssemblySourceForRegistration(typeof(User).Assembly)
         );
 }
 public void Install( 
     Castle.Windsor.IWindsorContainer container, 
     Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(Component.For<IUser>().ImplementedBy<WebUser>());
     container.Register(Component.For<ILoginService>().ImplementedBy<LoginService>());
 }
 public void Install(Castle.Windsor.IWindsorContainer container,
 Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(Classes.FromThisAssembly()
      .BasedOn<ApiController>()
      .LifestylePerWebRequest());
 }
		static void Kernel_ComponentModelCreated(Castle.Core.ComponentModel model)
		{
			if (model.Services.First().IsGenericType && model.Services.First().GetGenericTypeDefinition().Equals(typeof(IHandleCommand<>)))
			{
				model.CustomComponentActivator = typeof(CommandHandlerComponentActivator);
			}
		}
		protected override object Instantiate(Castle.MicroKernel.CreationContext context)
		{
			Type systemType = (Type) 
				Model.ExtendedProperties[PrevalenceFacility.SystemTypePropertyKey];
			String dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, (String) 
				Model.ExtendedProperties[PrevalenceFacility.StorageDirPropertyKey]);
			bool autoVersionMigration = (bool) 
				Model.ExtendedProperties[PrevalenceFacility.AutoMigrationPropertyKey];
			bool resetStorage = (bool) 
				Model.ExtendedProperties[PrevalenceFacility.ResetStoragePropertyKey];
			float snapshotPeriod = (float)Model.ExtendedProperties[PrevalenceFacility.SnapshotPeriodPropertyKey];
			
			if (resetStorage)
			{
				DeleteStorageDir(dir);
			}

			PrevalenceEngine engine = PrevalenceActivator.CreateEngine( 
				systemType, 
				dir, 
				autoVersionMigration );

			if (snapshotPeriod > 0)
			{
				CreateSnapshotTaker(engine, snapshotPeriod);
			}

			return engine;
		}
Example #25
0
 public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(Component.For<Shell>());
     container.Register(Component.For<MainModule>());
     container.Register(Component.For<TeacherModule>());
     container.Register(Component.For<StackPanelRegionAdapter>());
 }
 public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
 {
     container.Register(
         Component.For<ContentFilterManager>(),
         Component.For<ContentFormatBuilder>()
         );
 }
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            container.Register(
                Component.For<CommandExecutor>(),
                Component.For<AppCommands>(),
                Component.For<TextChangedTrigger>(),

                Component.For<TasksModule>(),

                Component.For<ProgramService>(),

                Component.For<AppValueProvider>(),
                Component.For<VariablesStorage>(),

                Component.For<Context>(),

                Component.For<XmlDataSource<ItemsDb>>(),
                Component.For<DataStorage<ItemsDb>>(),

                Component.For<ProgramCommand>(),
                Component.For<StartProcessCommand>(),
                Component.For<TasksCommand>(),

                Component.For<MainViewModel>());
        }
 protected override void Resolve(Castle.Windsor.IWindsorContainer windsor)
 {
     //提前注册桩
     windsor.RegisterComponent(typeof(ProcessServiceMock));
     windsor.RegisterComponent(typeof(SchedulerServiceMock));
     base.Resolve(windsor);
 }
Example #29
0
		public void Install(IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
		{
			// use installer.
			// container.Install(new PersonInstaller());

			container.Register(Component.For<IPerson>().ImplementedBy<Person>());
		}
Example #30
0
        public Enemy(ObjectType mObjectType, ContentManager content,
            SpriteState defaultState, Castle castle, Vector2 SpritePosition)
            : base(mObjectType, content, defaultState, SpritePosition, Hostility.ENEMY)
        {
            isInPlay = true;
            this.hostility = Hostility.ENEMY;
            mFieldOfViewSize = 200;

            SetUnitAnimation();
            random = new Random();

            y = random.Next(25, 700);
            mDefaultTarget = new Rectangle(1400, y, 200, 775);
            mCurrentTarget = new Vector2(mDefaultTarget.X, mDefaultTarget.Y);

            mBehaviorEnemy = new BehaviorEnemy(1.0f);
            mObjectID = mGlobalID;
            mGlobalID++;

            enemyAttribute = new EnemyAttribute(this, content, castle);
            SetAttributes();
            this.AttackState = AttackState.READY;

            enemyAttribute.UpgradeAttack();
            enemyAttribute.UpgradeDefense();
        }
Example #31
0
        internal bool Edit(Castle original)
        {
            string sql          = @"
      UPDATE castles
      SET
      name = @Name,
      location = @Location,
      yearbuilt = @YearBuilt,
      timesinvaded = @TimesInvaded,
      imgurl = @ImgUrl
      WHERE id=@Id
      ";
            int    affectedRows = _Db.Execute(sql, original);

            return(affectedRows == 1);
        }
Example #32
0
        public Castle GetCastleFromJSon(string path)
        {
            Castle existingCastle = new Castle();

            using (StreamReader fileItem = File.OpenText(path))
                using (JsonTextReader reader = new JsonTextReader(fileItem))
                {
                    string jSonContent = fileItem.ReadToEnd();
                    existingCastle = JsonConvert.DeserializeObject <Castle>(jSonContent, new JsonSerializerSettings());
                }
            if (String.IsNullOrEmpty(existingCastle.Name))
            {
                existingCastle.Name = ConvertToUTF8(existingCastle.Name);
            }
            return(existingCastle);
        }
Example #33
0
        public void CastleMoveCastlePass()
        {
            //Setup
            var board = new Board()
            {
                Top    = Side.White,
                Bottom = Side.Black
            };
            var grid     = BoardHelper.GetEmptyBoard();
            var firstRow = BoardHelper.GetEmptyRow();
            var kingRow  = BoardHelper.GetEmptyRow();
            var lastRow  = BoardHelper.GetEmptyRow();

            var leftRook = new Peice
            {
                Type = PeiceType.Castle,
                X    = 0,
                Y    = 0
            };

            var rightRook = new Peice
            {
                Type = PeiceType.Castle,
                X    = 7,
                Y    = 0
            };

            var king = new Peice
            {
                Type = PeiceType.King,
                X    = 5,
                Y    = 0
            };

            firstRow[0] = leftRook;
            kingRow[0]  = king;
            lastRow[0]  = rightRook;

            grid[0] = firstRow;
            grid[5] = kingRow;
            grid[7] = lastRow;

            board.SetGrid(grid);

            Assert.True(Castle.CanMove(board, leftRook, 3, 0));
            Assert.True(Castle.CanMove(board, rightRook, -2, 0));
        }
Example #34
0
        public BattleViewModel(Clickers.Models.Army attackingArmy, Clickers.Models.Army defenseArmy, Castle attackedCastle)
        {
            this.AttackSoldiers  = new List <Soldier>();
            this.DefenseSoldiers = new List <Soldier>();
            this.AttackDeaths    = new List <Soldier>();
            this.DefenseDeaths   = new List <Soldier>();
            this.AttackedCastle  = attackedCastle;
            this.rng             = new Random();
            this.View            = new BattleReport();

            if (attackingArmy.Hero.Life <= 0 && defenseArmy.Hero != null && defenseArmy.Hero.Life > 0)
            {
                ArmyCreation(attackingArmy, AttackSoldiers);
                ArmyCreationWithHero(defenseArmy, DefenseSoldiers);
            }
            else if (defenseArmy.Hero.Life <= 0 && attackingArmy.Hero != null && attackingArmy.Hero.Life > 0)
            {
                ArmyCreation(defenseArmy, DefenseSoldiers);
                ArmyCreationWithHero(attackingArmy, AttackSoldiers);
            }
            else
            {
                ArmyCreation(attackingArmy, AttackSoldiers);
                ArmyCreation(defenseArmy, DefenseSoldiers);
            }

            Randomizer(AttackSoldiers);
            Randomizer(DefenseSoldiers);
            Fight();


            if (AttackWin == true)
            {
                view.WinOrLoseLabel.Content = "VICTOIRE";
            }
            else
            {
                view.WinOrLoseLabel.Content = "DÉFAITE..";
            }

            view.AllyUnitslose.Text   = "Unités attaquantes perdue : " + AttackDeaths.Count;
            view.AllyUnitsRest.Text   = "Unités attaquantes restantes : " + (GameViewModel.Instance.MainCastle.Army.AllSoldiers.Count - AttackDeaths.Count);
            view.EnnemyUnitslose.Text = "Unités défendantes perdue : " + DefenseDeaths.Count;
            view.EnnemyUnitsRest.Text = "Unités défendantes restantes : " + (GameViewModel.Instance.EnnemyCastle.Army.AllSoldiers.Count - DefenseDeaths.Count);
            Switcher.Switch(view);
            EventGenerator();
        }
Example #35
0
 void Awake()
 {
     resources      = InitResourceList();
     resourceLimits = InitResourceList();
     Castle [] c = FindObjectsOfType <Castle>();
     for (int i = 0; i < c.Length; i++)
     {
         if (c [i].tag == "P1Castle")
         {
             playercastle = c [i];
         }
         else if (c [i].tag == "P2Castle")
         {
             enemycastle = c [i];
         }
     }
 }
        internal object EditCastle(Castle editCastle)
        {
            Castle original = GetCastleById(editCastle.Id);

            if (original == null)
            {
                throw new SystemException("INVALID ID");
            }
            else
            {
                original.Name      = editCastle.Name != null ? editCastle.Name : original.Name;
                original.King      = editCastle.King != null ? editCastle.King : original.King;
                original.Villagers = editCastle.Villagers != null ? editCastle.Villagers : original.Villagers;
                original.Armysize  = editCastle.Armysize != null ? editCastle.Armysize : original.Armysize;
                return(_repo.EditCastle(original));
            }
        }
Example #37
0
    // Start is called before the first frame update
    void Start()
    {
        castleScr = castle.GetComponent <Castle>();

        canvas = transform.parent.gameObject;

        towerPrewiew = new GameObject[towerType.Count];
        for (int i = 0; i < towerPrewiew.Length; i++)
        {
            towerPrewiew[i] = Towerbutton;
            // var prewiewImg = towerPrewiew[i].GetComponent<Image>();
            // var towerSR = towerType[i].GetComponent<SpriteRenderer>();
            // prewiewImg.sprite = towerSR.sprite;
            // prewiewImg.color = towerSR.color;
        }
        DeployButtons();
    }
Example #38
0
 public AirStrike(CharacterEnums.EDirection direction, Vector2 startLocation, int damage, HittableTarget target, Castle enemyCastle)
     : base(direction, startLocation, damage, target, enemyCastle)
 {
     this.target      = target;
     this.damage      = damage;
     this.enemyCastle = enemyCastle;
     targetMarker     = getTargetMarker();
     payload          = getPayload();
     if (target.myType == CharacterEnums.EType.AIR)
     {
         finalDestination = Constants.airHeight;
     }
     else
     {
         finalDestination = Constants.groundHeight;
     }
 }
Example #39
0
    public IEnumerator Attack()
    {
        for (int i = Rows.Count - 1; i >= 0; i--)
        {
            for (int s = Rows[i].Slots.Count - 1; s >= 0; s--)
            {
                GridSlot slot = Rows[i].Slots[s];
                if (!slot.IsEmpty)
                {
                    GridRow  opponentRow = grid.GetOpponentRow(Side, i);
                    GridSlot target      = opponentRow.GetFirstTarget(Side);
                    if (target != null)
                    {
                        Debug.Log("Target: " + target.Champion.Data.Name);
                        Vector3 pos = slot.Champion.transform.position;
                        slot.Champion.transform.DOMove(target.Champion.transform.position, GameManager.Instance.AttackDuration / 2).OnComplete(() =>
                        {
                            slot.Champion.transform.DOMove(pos, GameManager.Instance.AttackDuration / 2);
                            target.TakeDamage(slot.Champion.Data.Damage);
                        });
                        //animate
                    }
                    else
                    {
                        Debug.Log("Target was not found");
                        Castle  c   = grid.GetOpponentCastle(Side);
                        Vector3 pos = slot.Champion.transform.position;
                        slot.Champion.transform.DOMove(c.transform.position, GameManager.Instance.AttackDuration / 2).OnComplete(() =>
                        {
                            slot.Champion.transform.DOMove(pos, GameManager.Instance.AttackDuration / 2);
                            c.TakeDamage(slot.Champion.Data.Damage);
                        });


                        //animate
                    }
                    yield return(new WaitForSeconds(GameManager.Instance.AttackDuration));
                }
            }
        }
        if (OnAttackFinish != null)
        {
            OnAttackFinish(Side);
        }
        yield return(new WaitForSeconds(1f));
    }
        public override float GetScore(VirtualGame virtualGame)
        {
            float score = 0;

            Castle enemyCastle = Constants.Game.GetEnemyCastle();

            foreach (KeyValuePair <int, FutureLocation> pair in virtualGame.GetFutureLocations())
            {
                Location elfNextLocation = pair.Value.GetFutureLocation();

                float distance = elfNextLocation.Distance(enemyCastle);

                score -= distance / Constants.Game.ElfMaxSpeed;
            }

            return(score);
        }
Example #41
0
    public override void CREATE()
    {
        m_UltimateAttack = DEFAULT_ULTIMATE;
        m_Character      = GameObject.Find("character").GetComponent <Character>();
        Debug.Assert(m_Character);

        m_Castle = GameObject.Find("castle").GetComponent <Castle>();
        Debug.Assert(m_Castle);

        m_AttackDelay = 0;
        m_Damage      = DEFAULT_DAMAGE;
        m_Facing      = FACING_LEFT;
        m_Side        = ObjectSide.ENEMY_SIDE;

        initHealth(DEFAULT_HEALTH);
        GetComponent <BoxCollider2D>().isTrigger = true;
    }
Example #42
0
    protected override void OnTriggerEnter2D(Collider2D collision)
    {
        base.OnTriggerEnter2D(collision);

        Castle castle = collision.GetComponent <Castle>();

        if (castle != null)
        {
            if (impactEffect != null)
            {
                Impact();
            }

            Destroy(gameObject);
            castle.TakeDamage(Damage);
        }
    }
Example #43
0
        public void CastleMoveBlockedFail()
        {
            //Setup
            var grid = BoardHelper.GetEmptyBoard();
            var row1 = BoardHelper.GetEmptyRow();
            var row2 = BoardHelper.GetEmptyRow();

            var rook = new Peice
            {
                Type = PeiceType.Castle,
                X    = 0,
                Y    = 0
            };

            var verticalBlock = new Peice
            {
                Type = PeiceType.Pawn,
                X    = 0,
                Y    = 1
            };

            var horizontalBlock = new Peice
            {
                Type = PeiceType.Pawn,
                X    = 1,
                Y    = 0
            };

            row1[0] = rook;
            row1[1] = verticalBlock;
            row2[0] = horizontalBlock;

            grid[0] = row1;
            grid[1] = row2;

            var board = new Board()
            {
                Top    = Side.White,
                Bottom = Side.Black
            };

            board.SetGrid(grid);

            Assert.False(Castle.CanMove(board, rook, 0, 7));
            Assert.False(Castle.CanMove(board, rook, 7, 0));
        }
Example #44
0
        private unsafe void ReQuestCastleWar(TPlayObject PlayObject, string sIndex)
        {
            TUserItem * UserItem;
            TUserCastle Castle;
            int         nIndex;

            try
            {
                nIndex = HUtil32.Str_ToInt(sIndex, -1);
                if (nIndex < 0)
                {
                    nIndex = 0;
                }
                Castle = M2Share.g_CastleManager.GetCastle(nIndex);
                if (PlayObject.IsGuildMaster() && !Castle.IsMember(PlayObject))
                {
                    UserItem = PlayObject.CheckItems(M2Share.g_Config.sZumaPiece);
                    if (UserItem != null)
                    {
                        if (Castle.AddAttackerInfo(PlayObject.m_MyGuild, 0))
                        {
                            PlayObject.SendDelItems(UserItem);
                            PlayObject.DelBagItem(UserItem->MakeIndex, M2Share.g_Config.sZumaPiece);
                            this.GotoLable(PlayObject, "~@request_ok", false);
                        }
                        else
                        {
                            PlayObject.SysMsg("您现在无法请求攻城!!!", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        PlayObject.SysMsg("您没有" + M2Share.g_Config.sZumaPiece + "!!!", TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                else
                {
                    PlayObject.SysMsg("您的请求被取消!!!", TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
            catch
            {
                M2Share.MainOutMessage("{异常} TGuildOfficial.ReQuestCastleWar");
            }
        }
    private void Start()
    {
        Monitor.SetActive(true);

        if (!training)
        {
            teams = new List <List <GameObject> >();

            while (teams.Count < numTeams)
            {
                teams.Add(new List <GameObject>());
            }

            Agent[] agents = FindObjectsOfType(typeof(Agent)) as Agent[];
            for (int i = 0; i < agents.Length; i++)
            {
                UnitAgent unit = agents[i].GetComponent <UnitAgent>();

                teams[unit.team].Add(agents[i].gameObject);
            }

            castles = new List <GameObject>();

            for (int i = 0; i < teams.Count; i++)
            {
                Castle castle = Instantiate(CastlePrefab).GetComponent <Castle>();
                castle.SetTeam(teams[i], i);
                MeshRenderer mesh = castle.GetComponentInChildren <MeshRenderer>();
                Material[]   mat  = mesh.materials;
                mat[0]         = Colors[i];
                mesh.materials = mat;

                castles.Add(castle.gameObject);
            }

            gameState  = FindObjectOfType(typeof(GameState)) as GameState;
            controller = FindObjectOfType(typeof(GameController)) as GameController;
            maxRange   = 25;

            resetButton = Instantiate(resetButton);
            resetButton.GetComponentInChildren <Button>().onClick.AddListener(ResetAcademy);

            ResetAcademy();
        }
    }
Example #46
0
        public override float GetScore(VirtualGame virtualGame)
        {
            float score = 0;

            Castle enemyCastle = Constants.Game.GetEnemyCastle();

            foreach (KeyValuePair <int, VirtualLavaGiant> pair in virtualGame.futureLavaGiants)
            {
                int damageToCastle = Utilities.PredictFutureDamage(pair.Value.location, enemyCastle, Constants.Game.LavaGiantAttackRange, Constants.Game.LavaGiantMaxSpeed, Constants.Game.LavaGiantAttackMultiplier, Constants.Game.LavaGiantMaxHealth, Constants.Game.LavaGiantSuffocationPerTurn);

                if (damageToCastle > minimumDamageOutput)
                {
                    score++;
                }
            }

            return(score);
        }
    // Init function for launching the playercontroller in play mode.
    public void InitPlayMode()
    {
        levelRef = FindObjectOfType <MainLevel>();

        SetCameraRails();

        UIMenuRef       = levelRef.GetComponent <MenuManager>();
        spawnManagerRef = levelRef.GetComponent <SpawnManager>();
        mapManagerRef   = levelRef.GetComponent <MapEditorManager>();

        // Index 0 of the tileMap's structure Palette is the Castle Prefab.
        castleRef = spawnManagerRef.castleRef;

        levelRef.GetComponent <MainLevel>().SetGameState(MainLevel.GameState.PLACECASTLE);
        UIMenuRef.OpenMenu(UIMenuRef.placeCastleNotif);

        this.enabled = true;
    }
        public static void HandleCollision(IPlayer player, Castle castle)
        {
            Vector2 playerLocation = player.MovementState.Location;
            Vector2 castleLocation = castle.SceneryPhysics.Location;

            float castleDoorRightBoundary  = (castleLocation.X + (castle.Rectangle.Width - Utils.Instance.CastleDoorRelaiveLocationX));
            float castleDoorLeftBoundary   = (castleLocation.X + Utils.Instance.CastleDoorRelaiveLocationX);
            float castleDoorTopBoundary    = (castleLocation.Y + Utils.Instance.CastleDoorRelaiveLocationY);
            float castleDoorButtomBoundary = (castleLocation.Y + castle.Rectangle.Height);

            bool playerDoorRelativeLocationX = (playerLocation.X <= castleDoorRightBoundary) && (playerLocation.X >= castleDoorLeftBoundary);
            bool playerDoorRelativeLocationY = (playerLocation.Y <= castleDoorButtomBoundary) && (playerLocation.Y >= castleDoorTopBoundary);

            if (playerDoorRelativeLocationX && playerDoorRelativeLocationY)
            {
                SuperMarioBros.Instance.GameStateManager.Win = true;
            }
        }
Example #49
0
        public void Castle_UpdateTypeTest()
        {
            Castle castle1 = new Castle(new Vector2(0, 0), "aType");
            Castle castle2 = new Castle(new Vector2(0, 0), "aType");
            Castle castle3 = new Castle(new Vector2(0, 0), "aType");

            castle1.UpdateType("Small");
            castle2.UpdateType("Big");
            castle3.UpdateType("");

            Rectangle expectedSource1 = new Rectangle(158, 96, 94, 80);
            Rectangle expectedSource2 = new Rectangle(0, 0, 158, 176);
            Rectangle expectedSource3 = Rectangle.Empty;

            Assert.AreEqual(castle1.Source, expectedSource1);
            Assert.AreEqual(castle2.Source, expectedSource2);
            Assert.AreEqual(castle3.Source, expectedSource3);
        }
Example #50
0
    void Awake()
    {
        _health         = _maxHealth;
        _castle         = GameObject.Find("Castle").GetComponent <Castle>();
        _player         = GameObject.Find("Player").GetComponent <Player>();
        _splineFollower = GetComponent <SplineFollower>();
        _waveManager    = GameObject.Find("WaveManager").GetComponent <WaveManager>();
        _rigidbody      = GetComponentInChildren <Rigidbody>();
        _animator       = GetComponent <Animator>();

        // increase health every 2 rounds
        int waveNumber = _waveManager.GetWaveNumber();

        if (waveNumber % 2 == 1)
        {
            _health += (_waveManager.GetWaveNumber() - 1) * 3;
        }
    }
Example #51
0
    private void CreateCastle(float height, float xPosition, bool createBottom)
    {
        //CastleTop
        Transform head = Instantiate(GameAssets.GetInstance().pfTopCastle);
        float     CastleTopPosition;

        if (createBottom)
        {
            CastleTopPosition = -CameraOrthoSize + height - TamTopCastle * .5f;
        }
        else
        {
            CastleTopPosition = +CameraOrthoSize - height - TamTopCastle * .5f;
        }
        head.position = new Vector3(xPosition, CastleTopPosition);

        //CastleBody
        Transform body = Instantiate(GameAssets.GetInstance().pfCastleBody);
        float     CastleBodyPosition;

        if (createBottom)
        {
            CastleBodyPosition = -CameraOrthoSize;
        }
        else
        {
            CastleBodyPosition = +CameraOrthoSize;
            body.localScale    = new Vector3(1, -1, 1);
        }
        body.position = new Vector3(xPosition, CastleBodyPosition);

        SpriteRenderer CastleBodySprite = body.GetComponent <SpriteRenderer>();

        CastleBodySprite.size = new Vector2(TamCastle, height);

        BoxCollider2D boxcolliderbody = body.GetComponent <BoxCollider2D>();

        boxcolliderbody.size   = new Vector2(TamCastle, height);
        boxcolliderbody.offset = new Vector2(0f, height * 0.5f);

        Castle castle = new Castle(head, body, createBottom);

        castleList.Add(castle);
    }
Example #52
0
 private void HandleCastleMovement()
 {
     for (int i = 0; i < castleList.Count; i++)
     {
         Castle castle = castleList[i];
         bool   isToTheRightOfDragon = castle.GetXposition() > DragonPosition;
         castle.Move();
         if (isToTheRightOfDragon && castle.GetXposition() <= DragonPosition && castle.IsBottom())
         {
             castlePassedCount++;
         }
         if (castle.GetXposition() < destroyPosition)
         {
             castle.DestroySelf();
             castleList.Remove(castle);
             i--;
         }
     }
 }
Example #53
0
        public HandlePort(Game game)
        {
            this.game           = game;
            this.EnemyCastle    = game.GetEnemyCastle();
            this.EnemyCreatures = game.GetEnemyLavaGiants();
            this.server         = new Server();
            this.Myp            = (from element in game.GetMyPortals() orderby element.Distance(game.GetMyCastle()) select element).ToList();


            if (Myp.Count == 1)
            {
                this.DefPortal = Myp[0];
            }
            else if (Myp.Count > 1)
            {
                this.DefPortal = Myp[0];
                this.AttPortal = Myp[Myp.Count - 1];
            }
        }
Example #54
0
        // 取得角色所在座标的城堡
        public TUserCastle InCastleWarArea(TBaseObject BaseObject)
        {
            TUserCastle result = null;
            TUserCastle Castle;

            if (m_CastleList.Count > 0)
            {
                for (int I = 0; I < m_CastleList.Count; I++)
                {
                    Castle = m_CastleList[I];
                    if (Castle.InCastleWarArea(BaseObject.m_PEnvir, BaseObject.m_nCurrX, BaseObject.m_nCurrY))
                    {
                        result = Castle;
                        break;
                    }
                }
            }
            return(result);
        }
Example #55
0
    protected virtual void Update()
    {
        PlayerUpdate();
        EnemyUpdate();

        foreach (GameObject g in troops)
        {
            g.transform.SetParent(gameObject.transform);
        }
        foreach (GameObject g in objectives)
        {
            g.transform.SetParent(gameObject.transform);
        }

        if (Cast.side != side)
        {
            Cast = null;
        }
    }
Example #56
0
        public virtual void Create(Transform spawnLocation, uint id = 0)
        {
            this.id              = id;
            this._name           = "Player" + (id + 1).ToString().PadLeft(2, '0');
            this.gameObject.name = this._name;
            this._turnEnded      = false;

            this.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);

            this._spawnLocation = spawnLocation;

            this._castle = StructurePoolManager.instance.GetStartCastle(this);

            GameObject ui = GameObject.Instantiate(AssetManager.instance.playerUI, this.transform);

            ui.name                      = UIValues.Player.PLAYERUI;
            this._uiComponent            = this.gameObject.AddComponent <PlayerUI>();
            this._uiComponent.controller = this;
        }
Example #57
0
    /// <summary>
    /// Creates a castle, size must be 48x48
    /// </summary>
    /// <returns></returns>
    public static Castle GenerateCastle(int size)
    {
        Tile[,] buildingBase = new Tile[size, size];
        WorldObjectData[,] buildingObjects = new WorldObjectData[size, size];
        Castle c = new Castle(size, size);

        c.SetBuilding(buildingBase, buildingObjects);
        //c.Entrances.Add(new BuildingEntrance(new Vec2i(1, size / 2 - 2), new Vec2i(1, size / 2 + 2)));
        Vec2i entr = GenerateWallsFloorAndEntrance(size, size, c.BuildingObjects, c.BuildingTiles, 0, BuildingStyle.stone, entraceDis: size / 2);


        AddEntrance(c, 0, entr.x - 1);
        AddEntrance(c, 0, entr.x - 2);

        AddEntrance(c, 0, entr.x + 1);
        AddEntrance(c, 0, entr.x + 2);

        return(c);
    }
Example #58
0
        /// <summary>
        /// 是否在攻城战争区域
        /// </summary>
        /// <param name="Envir"></param>
        /// <param name="nX"></param>
        /// <param name="nY"></param>
        /// <returns></returns>
        public TUserCastle InCastleWarArea(TEnvirnoment Envir, int nX, int nY)
        {
            TUserCastle result = null;
            TUserCastle Castle;

            if (m_CastleList.Count > 0)
            {
                for (int I = 0; I < m_CastleList.Count; I++)
                {
                    Castle = m_CastleList[I];
                    if (Castle.InCastleWarArea(Envir, nX, nY))
                    {
                        result = Castle;
                        break;
                    }
                }
            }
            return(result);
        }
Example #59
0
    private void FocusCastle()
    {
        RaycastHit hit;

        Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit);
        try
        {
            if (hit.transform.GetComponent <Castle>() != null)
            {
                Castle rayCastedCastle = hit.transform.GetComponent <Castle>();
                if (rayCastedCastle.fromPlayer != GameManager.Instance.currentPlayer.playerNumber)
                {
                    BattleManager.Instance.ManualCastleFocus(hit.transform.GetComponent <Castle>().fromPlayer, hit.transform.GetComponent <Castle>());
                }
            }
        } catch (System.NullReferenceException)
        {
        }
    }
Example #60
0
        private async void CustomGameGeneration(string CastleName, string customFolder)
        {
            MySQLFullDB mySQLFullDB = new MySQLFullDB();

            mySQLFullDB.InitCustomLocalMySQL(customFolder + "//");
            Castle newCastle = Json.JsonManager.Instance.GetCastleFromJSon(AllPath.Instance.JsonCustomFolder + customFolder + "//" + AllPath.Instance.CustomCastle);

            newCastle.Name = CastleName;
            await myCastleManager.Insert(newCastle);

            Castle enemyCastle = new Castle()
            {
                Name = "Méchant chato", Life = 100
            };
            await myCastleManager.Insert(enemyCastle);

            MainCastleView newPage = new MainCastleView();

            Switcher.Switch(newPage);
        }