Exemplo n.º 1
0
    public override void Ready()
    {
        Transform Prefab = null;

        switch (Type)
        {
        case EnmType.Enm01:
            Prefab = FloorManager.Instance.Enm01Prefab;
            break;
        }

        Transform tComponen = UnityEngine.Object.Instantiate(Prefab, new Vector3(X, Y, ZPos), Quaternion.identity) as Transform;

        tComponen.gameObject.name = Name;

        UnitControl unitCtl = tComponen.gameObject.GetComponent(typeof(UnitControl)) as UnitControl;

        // memo Stateにより表示状態を変更
        switch (State)
        {
        case EnmState.Hide:
            unitCtl.ReqChangeHide();
            break;

        case EnmState.Active:
            unitCtl.ReqChangeActive();
            break;
        }

        SetPanelEvent(Vector2I.InvalidPos, Vector2);

        base.Ready();
    }
Exemplo n.º 2
0
    //for LOS checking along a path,
    //return true if the unit will be seen by hostile faction if the unit moves along the path, false if otherwise
    bool CheckEncounterOnPath(Tile srcTile, Tile targetTile)
    {
        List <Tile>   path          = AStar.SearchWalkableTile(srcTile, targetTile);
        List <UnitTB> allPlayerUnit = UnitControl.GetAllUnitsOfFaction(0);

        bool visibleToPlayer = false;

        for (int i = 0; i < path.Count; i++)
        {
            Tile tile = path[0];
            for (int j = 0; j < allPlayerUnit.Count; j++)
            {
                if (GridManager.IsInLOS(tile, allPlayerUnit[j].occupiedTile))
                {
                    int dist = GridManager.Distance(tile, allPlayerUnit[j].occupiedTile);
                    if (dist <= allPlayerUnit[j].GetSight())
                    {
                        visibleToPlayer = true;
                        break;
                    }
                }
            }
        }
        return(visibleToPlayer);
    }
Exemplo n.º 3
0
    public void SetUp(SkeletonData setUpData)
    {
        root      = setUpData.rootTransform;
        rightHand = setUpData.rightHand;
        leftHand  = setUpData.leftHand;

        leftArmPart          = setUpData.leftArmPart;
        leftArmPart.Skeleton = this;

        rightArmPart          = setUpData.rightArmPart;
        rightArmPart.Skeleton = this;

        leftLegPart          = setUpData.leftLegPart;
        leftLegPart.Skeleton = this;

        rightLegPart          = setUpData.rightLegPart;
        rightLegPart.Skeleton = this;

        headPart          = setUpData.headPart;
        headPart.Skeleton = this;

        torsoPart          = setUpData.torsoPart;
        torsoPart.Skeleton = this;

        foreach (JointData joint in setUpData.joints)
        {
            SetUpJoint(joint, setUpData.layerName);
        }
        unitControl = GetComponent <UnitControl>();
        animator    = GetComponent <Animator>();
        gameManager = GameManager.Instance;
    }
Exemplo n.º 4
0
    public override void StateUpdate()
    {
        base.StateUpdate();
        if (!brain.CurrentTarget || brain.CurrentTarget.IsDestroyed)
        {
            brain.State = "Idle";
            return;
        }
        if (!CanSeeEnemy(brain.CurrentTarget))
        {
            brain.State = "Idle";
            return;
        }

        if (brain.InMeleeRange || brain.InMissileRange)
        {
            animator.SetTrigger("ChargeAttack");
            brain.State = "Attacking";
        }

        float       distance     = brain.DistanceToTarget;
        UnitControl betterTarget = brain.ScanForTargets();

        if (betterTarget && betterTarget != brain.CurrentTarget)
        {
            brain.AttackTarget(betterTarget);
        }
    }
Exemplo n.º 5
0
    void Update()
    {
        if (coolDownTimer > 0)
        {
            coolDownTimer -= Time.deltaTime;
            return;
        }
        if (!isReady || orders.Count < 1)
        {
            return;
        }

        UnitOrder   order          = orders[0];
        GameObject  newUnit        = gameManager.UnitFactory.CreateUnit(order.unitType, spawnPoint.position, spawnPoint.rotation);
        UnitControl newUnitControl = newUnit.GetComponent <UnitControl>();

        order.owner.AddUnit(newUnitControl);
        newUnitControl.TeamName = order.owner.tag;
        newUnitControl.UnitType = order.unitType;
        newUnitControl.Cluster  = order.owner;
        newUnit.name            = order.owner.tag + "-" + order.unitType;
        newUnit.layer           = LayerMask.NameToLayer(order.owner.tag);
        newUnit.GetComponent <UnitBrain>().MoveTo(order.owner.transform.position);
        order.amount--;
        coolDownTimer = coolDown;
        if (order.amount <= 0)
        {
            orders.Remove(order);
        }
    }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (UnitControl.FindObjectOfType <UnitControl>().unitsSpawned)
     {
         spawnAnim.SetBool("spawnNow", false);
     }
 }
Exemplo n.º 7
0
    void explode(GameObject target)
    {
        GameObject[] units = GameObject.FindGameObjectsWithTag("Unit");

        foreach (GameObject unit in units)
        {
            UnitControl unitControl = unit.GetComponent <UnitControl>();

            if (unitControl != null)
            {
                if (unit == target)
                {
                    unitControl.takeDamage(damage);
                }
                else
                {
                    float dist = Vector3.Distance(transform.position, unit.transform.position);
                    if (dist < range)
                    {
                        unitControl.takeDamage((int)(damage * (1f - dist / range)));
                    }
                }
            }
        }

        Instantiate(explosionEffect, transform.position, new Quaternion());
        Destroy(gameObject);
    }
Exemplo n.º 8
0
 public void UnitHit(UnitControl unitControl, CombotPart part)
 {
     if (unitControl.IsPlayer)
     {
         uiControl.AddDamageUI(part);
     }
 }
Exemplo n.º 9
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag.Equals("Projectile"))
        {
            return;
        }
        inAir = false;
        if (explosive)
        {
            Explode();
            return;
        }

        if (collision.gameObject.tag.Equals(enemyTag))
        {
            Destroy(rbody);
            Destroy(myCollision);
            transform.parent = collision.transform;
            UnitControl enemy = collision.gameObject.GetComponent <UnitControl>();
            if (enemy)
            {
                enemy.TakeDamage(damage);
            }
        }
    }
Exemplo n.º 10
0
 protected override void CollidedWithEnemy(UnitControl enemy)
 {
     if (isActive && enemy.transform.tag.Equals(brain.EnemyTag))
     {
         animator.SetTrigger("ChargeAttack");
         brain.AttackTarget(enemy.gameObject.GetComponent <UnitControl>());
     }
 }
Exemplo n.º 11
0
 public DamageInfo(float _amount, DamageType _type, UnitControl _attacker)
 {
     damageAmount  = _amount;
     type          = _type;
     position      = _attacker.transform.position;
     attacker      = _attacker;
     isDirectional = true;
 }
Exemplo n.º 12
0
 void Start()
 {
     unitAttack  = GetComponent <UnitAttack>();
     unitControl = GetComponent <UnitControl>();
     animator    = GetComponent <Animator>();
     animator.SetFloat("random", Random.value);
     homePosition = transform.position;
 }
Exemplo n.º 13
0
 public DamageInfo(float _amount, DamageType _type)
 {
     damageAmount  = _amount;
     type          = _type;
     position      = Vector3.zero;
     attacker      = null;
     isDirectional = false;
 }
Exemplo n.º 14
0
 public DamageInfo(float _amount, DamageType _type, Vector3 _position)
 {
     damageAmount  = _amount;
     type          = _type;
     position      = _position;
     attacker      = null;
     isDirectional = true;
 }
Exemplo n.º 15
0
 public UnitControlMovement(int x, int y, GridControl tiles, UnitControl units)
 {
     this.sizex = x;
     this.sizey = y;
     TilesSpec  = tiles;
     UnitsSpec  = units;
     clear();
 }
Exemplo n.º 16
0
 public void RemoveUnit(UnitControl unit)
 {
     Units.Remove(unit);
     unitLost.Invoke(unit);
     if (Units.Count == 0)
     {
         gameManager.InputControl.RemoveCluster(this);
     }
 }
Exemplo n.º 17
0
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!unitControl)
        {
            unitControl = animator.gameObject.GetComponent <UnitControl>();
        }

        unitControl.DefenseComplete();
    }
Exemplo n.º 18
0
    private void OnCollisionEnter(Collision other)
    {
        UnitControl control = other.gameObject.GetComponent <UnitControl>();

        if (control && control.transform.tag.Equals(brain.EnemyTag))
        {
            CollidedWithEnemy(control);
        }
    }
Exemplo n.º 19
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (!unitControl)
        {
            unitControl = animator.gameObject.GetComponent <UnitControl>();
        }

        unitControl.SetAttackState(true);
    }
Exemplo n.º 20
0
 public virtual void StateInit()
 {
     gameManager = GameManager.Instance;
     ai          = GetComponent <AIController>();
     unitControl = GetComponent <UnitControl>();
     unitAttack  = GetComponent <UnitAttack>();
     unitMover   = GetComponent <UnitMover>();
     mapControl  = gameManager.ActiveMap;
 }
Exemplo n.º 21
0
 public virtual void Move(Vector3 pos)
 {
     if (IsSelected)
     {
         unitControl = gameObject.GetComponent <UnitControl>();
         unitControl.GoToPositions(pos);
         Deselect();
     }
 }
Exemplo n.º 22
0
    public virtual void Init(UnitControl _unitControl)
    {
        unitControl = _unitControl;

        if (animOverride != null)
        {
            unitControl.gameObject.GetComponent <Animator>().runtimeAnimatorController = animOverride;
        }
    }
Exemplo n.º 23
0
 public virtual void StateInit()
 {
     unitControl = GetComponent <UnitControl>();
     animator    = GetComponent <Animator>();
     brain       = GetComponent <UnitBrain>();
     navAgent    = GetComponent <NavMeshAgent>();
     rbody       = GetComponent <Rigidbody>();
     terrainMask = LayerMask.GetMask("Terrain");
 }
Exemplo n.º 24
0
    virtual public void FinishAttack()
    {
        UnitControl enemy = unitControl.GetCurrentEnemy();

        if (enemy)
        {
            enemy.TakeDamage(damage);
        }
    }
Exemplo n.º 25
0
        ///////////////////////////////////////////////////////////////////////////
        // Functions to persist attributes

        private void SaveDimension(CSSAttribute ai, UnitControl unitDim)
        {
            string value = SaveDimensionUI(unitDim);

            Debug.Assert(value != null,
                         "saveDimensionUI returned null!");

            ai.SaveAttribute(GetSelectedStyles(), value);
        }
Exemplo n.º 26
0
 void Start()
 {
     animator    = GetComponent <Animator>();
     gameManager = GameManager.instance;
     unitControl = GetComponent <UnitControl>();
     Build();
     InitializeParts();
     StartCoroutine(BindAnimator());
 }
Exemplo n.º 27
0
    public static void HealAllFriendlyUnit(int factionID)
    {
        List <UnitTB> list = UnitControl.GetAllUnitsOfFaction(factionID);

        foreach (UnitTB unit in list)
        {
            int val = Random.Range(2, 6);
            unit.ApplyHeal(val);
        }
    }
Exemplo n.º 28
0
    IEnumerator BindAnimator()
    {
        yield return(new WaitForEndOfFrame());

        animator.Rebind();
        unitControl = GetComponent <UnitControl>();
        SetupAttachPoints(unitControl);
        unitControl.Init();
        Destroy(this);
    }
Exemplo n.º 29
0
        private void AddUnitControl(Unit unit)
        {
            UnitControl unitControl = new UnitControl(unit);

            unitControl.Click += this.UnitControl_Click;
            this.pnlField.Controls.Add(unitControl);
            unitControl.BringToFront();

            this.unitControls.Add(unit, unitControl);
        }
Exemplo n.º 30
0
        private void UnitControl_Click(object sender, EventArgs e)
        {
            UnitControl unitControl = (UnitControl)sender;

            DataGridViewRow row = this.GetRow(unitControl.Unit);

            row.Selected = true;

            this.game.OnSelectUnit(unitControl.Unit);
        }
Exemplo n.º 31
0
	void Awake(){
		instance=this;
		
		List<Tile> allTiles=GridManager.GetAllTiles();
		foreach(Tile tile in allTiles){
			if(tile.unit!=null){
				UnitTB unit=tile.unit;
				allUnits.Add(unit);
			}
		}
		
		currentUnitTurnID=-1;
#if ibox
		if(playerUnits==null || playerUnits.Count==0){
			playerUnits=new List<PlayerUnits>();
			playerUnits.Add(new PlayerUnits(GameControlTB.instance.playerFactionID[0]));
		}
#endif
	}
Exemplo n.º 32
0
    void Awake()
    {
        gc=(GameControlTB)target;
        uc=gc.gameObject.GetComponent<UnitControl>();

        InitLabel();

        if(gc.playerFactionID==null || gc.playerFactionID.Count==0){
            gc.playerFactionID=new List<int>();
            gc.playerFactionID.Add(0);
        }
    }
Exemplo n.º 33
0
    void Awake()
    {
        LoadUnit();

        uc=(UnitControl)target;
        gc=uc.gameObject.GetComponent<GameControlTB>();
        if(gc!=null) InitPlayerUnitsList();
    }