Example #1
0
    private void Update()
    {
        MousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        // If the mouse on the game board and click right button
        if (Input.GetMouseButtonDown(1) && IsMouseInGameBoard())
        {
            // if selected product is Soldier
            if (_selectedProduct != null && _selectedProduct.tag.Equals("Soldier"))
            {
                RaycastHit2D hit = Physics2D.Raycast(MousePosition, Vector2.zero, 2f);
                if (hit.collider != null)
                {
                    var hitObject = hit.collider.gameObject;
                    if (hitObject.tag.Equals("Ground") && hitObject.GetComponent <GroundTileViewModel>().IsWalkable)
                    {
                        SoldierViewModel soldierViewModel = _selectedProduct.GetComponent <SoldierViewModel>();
                        soldierViewModel.SetEndGroundTile(hitObject);
                    }
                }
            }
        }

        // if any object selected then Deselect Product
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            DeselectProduct();
        }

        // Select Product on the Map
        if (Input.GetMouseButtonDown(0) && IsMouseInGameBoard())
        {
            RaycastHit2D hit = Physics2D.Raycast(MousePosition, Vector2.zero, 2f);
            if (hit.collider != null)
            {
                var hitObject = hit.collider.gameObject;
                if (hitObject.tag.Equals("Building") || hitObject.tag.Equals("Soldier"))
                {
                    SelectProduct(hitObject);
                }
            }
            else
            {
                GameManager.Instance.HideProductInformation();
            }
        }
    }
	public override void InitializeSoldier(SoldierViewModel viewModel) {
		base.InitializeSoldier(viewModel);
        // This is called when a SoldierViewModel is createdmove
		viewModel.Physique = 70;
		viewModel.HitPoint = 70;
		viewModel.Dodge = 30;
		viewModel.WeaponProficiency = 90;
		viewModel.Health = 1999;
		viewModel.AttackSpeed  = 1;
		viewModel.InitialMorale =  80;
		viewModel.moraleStandard = 70;
		viewModel.Prestige = 100;
		//viewModel.Weapon = new Weapons{Weight = 2,OtherHit = 50, CriticalHit = 30, FatalHit = 20, Sharpness = 90, IsSharp = true};
		//viewModel.Armor = new Armors {Weight = 2, OtherCover = 30, CriticalCover = 30, FatalCover = 30, Hardness =30};
		//viewModel.Shield = new Shields{Weight = 0 , BlockRate = 0, Hardness =0};
		//viewModel.Formation = new Formations{HitPoint = 10, Dodge = 10, Morale =5};
	}
	public override void ChangeActionStyle(SoldierViewModel viewModel) {
        base.ChangeActionStyle(viewModel);

		if(viewModel.Action == ActionStyle.ATTACK)
		{
			//Debug.Log ("ActionStyle is ATTACK");
		}

		else if(viewModel.Action == ActionStyle.ASSAULT)
		{
			//Debug.Log ("ActionStyle is ASSAULT");
		}

		else if(viewModel.Action == ActionStyle.FEINT)
		{
			//Debug.Log ("ActionStyle is FEINT");
		}

		else if(viewModel.Action == ActionStyle.PIN)
		{
			//Debug.Log ("ActionStyle is PIN");
		}

		else if(viewModel.Action == ActionStyle.RAID)
		{
			//Debug.Log ("ActionStyle is RAID");
		}

		else if(viewModel.Action == ActionStyle.SEARCH)
		{
			//Debug.Log ("ActionStyle is SEARCH");
		}

		else if(viewModel.Action == ActionStyle.YAWP)
		{
			//Debug.Log ("ActionStyle is YWAP");
		}
    }
Example #4
0
    /// <summary>
    /// Creates a soldier around the selected barrack
    /// </summary>
    public void SpawnSoldier()
    {
        if (_selectedProduct != null && _selectedProduct.name.Contains("Barrack"))
        {
            GameObject emptyGroundTile = _selectedProduct.GetComponent <BuildingViewModel>()
                                         .GetEmptyGroundTileNearTheSelectedBarrack(_createdGroundTileModels);

            if (emptyGroundTile != null)
            {
                emptyGroundTile.GetComponent <GroundTileViewModel>().IsWalkable = false;

                IProduct product        = new SoldierUnit("Soldier Unit", ProductType.Soldier, false, 1f);
                var      createdProduct = ViewFactory.Create <IProduct, SoldierViewModel>(product, Resources.Load <GameObject>("Prefabs/SoldierUnit"), null);
                createdProduct.name = "SoldierUnit";
                SoldierViewModel soldierViewModel = createdProduct.GetComponent <SoldierViewModel>();
                soldierViewModel.SetPosition(new Vector2(emptyGroundTile.transform.position.x, emptyGroundTile.transform.position.y));
                soldierViewModel.SetCurrentGroundTile(emptyGroundTile);
            }
            else
            {
                GameManager.Instance.GiveNotSuitableAreaForSpawnWarning();
            }
        }
    }
 public virtual void ChangeActionStyle(SoldierViewModel viewModel) {
 }
 public virtual void InitializeSoldier(SoldierViewModel viewModel) {
     // This is called when a SoldierViewModel is created
     viewModel.ChangeActionStyle.Action = this.ChangeActionStyleHandler;
     SoldierViewModelManager.Add(viewModel);
 }