Exemplo n.º 1
0
    IEnumerator SpellSkillIE(UnitCtrl target)
    {
        //停頓單位, 面向施法方向, 命令攻擊動作
        movCtrl.SetUnitBusy(0.7f);
        movCtrl.SetFaceDirect(target.transform.position);
        ani.SetTrigger("Attack");

        yield return(new WaitForSeconds(0.3f));

        //Shoot ok

        //GlobalInfo.current.nowBallOwner = target.gameObject;
        target.hasBall = true;
        //GlobalInfo.current.spellPad.SetActive (false);
        //target.GetComponent<LocalPlayerSetting> ().SetLocalSkillPad ();
        hasBall = false;


        GameObject projectile = Instantiate(prefabs_ball, gameObject.transform.position + new Vector3(0, 2, 0), Quaternion.identity) as GameObject;

        projectile.transform.LookAt(target.transform.position);
        projectile.GetComponent <MagicProjectileScript> ().impactNormal = new Vector3(0, 1, 0);
        MagicBallScript _ball = projectile.GetComponent <MagicBallScript> ();

        _ball.SetSourceAndTarget(gameObject, target.gameObject);

        NetworkServer.Spawn(projectile);
    }
Exemplo n.º 2
0
    public void SwapUnit(CellCtrl curCell)
    {
        UnitCtrl temp = Unit;

        Unit         = curCell.Unit;
        curCell.Unit = temp;
    }
Exemplo n.º 3
0
        public JObject GetUnitList(string sid)
        {
            string   acc      = "AC003";
            UnitCtrl unitCtrl = new UnitCtrl(acc);
            var      list     = new List <Units>();

            if (!string.IsNullOrWhiteSpace(sid))
            {
                list = unitCtrl.GetList(sid);
            }
            else
            {
                list = unitCtrl.GetList();
            }
            JObject json = new JObject(
                new JProperty("code", 0),
                new JProperty("msg", unitCtrl.Msg),
                new JProperty("data",
                              new JArray(
                                  from r in list
                                  select new JObject(
                                      new JProperty("ID", r.SID),
                                      new JProperty("UnitName", r.UnitName)
                                      ))));

            return(json);
        }
Exemplo n.º 4
0
            public override void Works(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (target != null)
                {
                    //Debug.Log(Vector2.Distance(unitCtrl.Pos, target.Pos)+"/"+ (unitCtrl.Stat("Radius") + target.Radius + 0.1f));
                    if (Vector2.Distance(unitCtrl.Pos, target.Pos) > unitCtrl.Stat("Radius") + target.Radius + 0.1f)
                    {
                        unitCtrl.MoveTarget(target);
                    }
                    else
                    {
                        Debug.Log("wow");
                        if (target.Type == eTargetType.Building && unitCtrl.Job == eUnitJob.Worker)
                        {
                            BuildingCtrl building = target.transform.GetComponent <BuildingCtrl>();
                            if (building.BuildingState == eBuildingState.Construction)
                            {
                                unitCtrl.receiptOrder(new Build(target));
                            }
                            else
                            {
                                building.EnterBuilding(unitCtrl);
                            }
                            target = null;
                        }
                        unitCtrl.Stop();
                    }
                }
            }
Exemplo n.º 5
0
    void Update()
    {
        Ray raySelect = camera.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(raySelect, out hit))
        {
            if (Input.GetButtonDown ("Fire1") && hit.transform.gameObject.tag == "Unit")
            {
                unitSelected = hit.transform.gameObject.GetComponent<UnitCtrl>();
            }
        }

        if (Input.GetButtonDown ("Fire2") && unitSelected != null)
        {
            //Debug.Log(unitSelected.test);
            if (hit.transform.gameObject.tag != "Enemy")
            {
                hitNoY = hit.point;
                hitNoY.y = 5.0f;
                unitSelected.targetMove = hitNoY;
                unitSelected.distanceInitial = Vector3.Distance(unitSelected.transform.position, hitNoY);
                unitSelected.distance = unitSelected.distanceInitial;
                //Debug.Log (hit.point);
            }
            else
            {
                unitSelected.targetInteract = hit.transform.gameObject;
            }
        }
    }
Exemplo n.º 6
0
        public virtual void Initialize(BasePartsData _target, List <ActionParameter> _actions, Skill _skill, List <NormalSkillEffect> _skillEffect, UnitCtrl _owner, float _height, bool _hasBlackOutTime, bool _isAbsolute, Vector3 _targetPosition, List <ShakeEffect> _shakes, eTargetBone _targetBone)
        {
            ShakeEffects = _shakes;
            IsAbsolute   = _isAbsolute;
            Skill        = _skill;
            Vector3 pos = _targetPosition;

            if (!IsAbsolute)
            {
                if (_targetBone == eTargetBone.FIXED_CENETER || _targetBone == eTargetBone.CENTER)
                {
                    pos = _target.GetButtontransformPosition() + _target.GetFixedCenterPos();
                }
                if (_targetBone == eTargetBone.BOTTOM)
                {
                    pos = _target.GetButtontransformPosition();
                }
                if (_targetBone == eTargetBone.HEAD)
                {
                    pos = GetHeadBonePos(_target);
                }
            }
            TargetPos  = pos;
            FireTarget = _target;
            _target.Owner.FirearmCtrlsOnMe.Add(this);
            SkillHitEffects = _skillEffect;
            EndActions      = _actions;
            owner           = _owner;
            SetInitialPosition();
            InitMoveType(_height, _owner);
            float distance = Vector3.Distance(TargetPos, initialPosistion) + 1;

            owner.StartCoroutine(UpdatePosition(distance));
        }
Exemplo n.º 7
0
    /// <summary>
    /// 每帧更新元素位置
    /// </summary>
    /// <param name="element"></param>
    void UpdateElementPosition(SKillAreaElement element)
    {
        if (allElementTrans[element] == null)
        {
            return;
        }
        switch (element)
        {
        case SKillAreaElement.OuterCircle:
            break;

        case SKillAreaElement.InnerCircle:
            allElementTrans[element].transform.position = GetCirclePosition(outerRadius);
            break;

        case SKillAreaElement.Cube:
        case SKillAreaElement.Sector60:
        case SKillAreaElement.Sector120:
            allElementTrans [element].transform.LookAt(GetCubeSectorLookAt());
            Target = TargetSelect(null, allElementTrans [element].gameObject);
            break;

        default:
            break;
        }
        if (!allElementTrans[element].gameObject.activeSelf)
        {
            allElementTrans[element].gameObject.SetActive(true);
        }
    }
Exemplo n.º 8
0
    public UnitCtrl CreateUnit(Vector3 unitPos, PlayerCtrl Owner, eUnitType unitType = eUnitType.People)
    {
        UnitCtrl unitTemp = null;

        switch (unitType)
        {
        case eUnitType.People:
            unitTemp = Instantiate(gUnitList[0], this.transform).GetComponent <UnitCtrl>();
            unitTemp.SetUnit(this, unitType, Owner, unitPos);
            unitList.Add(unitTemp);

            foreach (MeshRenderer mesh in unitTemp.transform.GetComponentsInChildren <MeshRenderer>())
            {
                if (mesh.transform.tag == "Unit")
                {
                    mesh.material = Owner.playerMater;
                }
                if (mesh.transform.tag == "Interface")
                {
                    if (Owner == gameMng.playerMng.CtrlPlayer)
                    {
                        mesh.material = RangeMater[0];
                    }
                    if (Owner != gameMng.playerMng.CtrlPlayer)
                    {
                        mesh.material = RangeMater[1];
                    }
                }
            }
            break;
        }
        return(unitTemp);
    }
Exemplo n.º 9
0
    bool IsWithinSelectionBounds(UnitCtrl unit)
    {
        Bounds viewportBounds = Utils.GetViewportBounds(mousePosition1, Input.mousePosition);

        return(viewportBounds.Contains(
                   Camera.main.WorldToViewportPoint(unit.transform.position)
                   ));
    }
Exemplo n.º 10
0
 public void ExitBuilding(UnitCtrl enterUnit)
 {
     if (enteredUnits.Contains(enterUnit))
     {
         nEnteredCnt--;
         enteredUnits.Remove(enterUnit);
         enterUnit.StateChange(eUnitState.Standby);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 플레이어 유닛 해지 메서드
 /// </summary>
 /// <param name="unit"></param>
 public void UnregisterPlayerUnit(UnitCtrl unit)
 {
     UnitList.Remove(unit);
     UseResource("WorkPopulation", 1);
     selectableObject.Remove(unit);
     if (unit.Job == eUnitJob.Leader)
     {
         playerMng.fallPlayer(this);
     }
 }
Exemplo n.º 12
0
 public UnitCtrl UnitCollisionPos(UnitCtrl self, Vector2 pos)
 {
     foreach (UnitCtrl unit in unitList)
     {
         if (Vector2.Distance(unit.Pos, pos) < unit.Stat("Radius") / 2 + self.Stat("Radius") / 2)
         {
             return(unit);
         }
     }
     return(null);
 }
Exemplo n.º 13
0
    //敌人行动
    void EnemyAction()
    {
        //敌人行动一次.
        UnitCtrl selfCtrl     = enemy;
        UnitCtrl targetCtrl   = player;
        Vector3  targetNewPos = GetNewPosition(targetCtrl.transform.position, selfCtrl.transform.position, targetCtrl.atkRange, targetCtrl.moveRange);
        Vector3  selfNewPos   = GetNewPosition(selfCtrl.transform.position, targetNewPos, selfCtrl.atkRange, selfCtrl.moveRange);

        selfCtrl.MoveTo(selfNewPos);
        selfCtrl.DirectionChange(GetAngle(selfNewPos, targetNewPos));
    }
Exemplo n.º 14
0
            public override bool Achievement(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (unitCtrl.X == targetPos.x && unitCtrl.Y == targetPos.y)
                {
                    unitCtrl.Stop();
                    return(true);
                }
                return(false);
            }
Exemplo n.º 15
0
            public override bool Achievement(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if ((target.TargetObject as BuildingCtrl).BuildingState != eBuildingState.Construction)
                {
                    unitCtrl.Stop();
                    return(true);
                }
                return(false);
            }
Exemplo n.º 16
0
 public void SetButton(UnitCtrl unitCtrl)
 {
     if (buttonType != ButtonType.typeC)
     {
         Debug.LogError("按钮样式错误!");
         return;
     }
     SetButton(unitCtrl.UnitData);
     SetHPAndTP(1, 1);
     SetAbnormalIcons();
 }
Exemplo n.º 17
0
            public override bool Achievement(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (target == null)
                {
                    Debug.Log("No");
                    unitCtrl.Stop();
                    return(true);
                }
                return(false);
            }
Exemplo n.º 18
0
            public override bool Achievement(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (target == null)
                {
                    unitCtrl.Stop();
                    return(true);
                }
                target = unitCtrl.EnemyInView();
                return(false);
            }
Exemplo n.º 19
0
 public bool WorkConstruction(UnitCtrl Worker, float fContribution)
 {
     fComplete += fContribution;
     RegisterUnit(Worker);
     if (buildingState == eBuildingState.Construction)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 20
0
    /// 选择提示器
    /// </summary>
    /// <param name="skill"></param>
    /// <param name="obj"></param>
    public UnitCtrl TargetSelect(SkillCtrl skill, GameObject skillArrowObj)
    {
        UnitCtrl unitSelect   = null;
        float    _skillRadius = 0.0f;

        //fRadius = skill.m_disRange;//技能的半径
        _skillRadius = outerRadius;
        UnitCtrl _caster    = Caster.GetComponent <UnitCtrl> ();
        Vector3  pos_caster = Caster.transform.position;

        Collider[]      bufCollider = Physics.OverlapSphere(pos_caster, _skillRadius);   //获取周围成员
        List <UnitCtrl> listUnit    = new List <UnitCtrl>();

        foreach (var item in bufCollider)
        {
            UnitCtrl unit = item.GetComponentInParent <UnitCtrl>();
            if (unit != null)
            {
                //if (!MainMgr.self.isWe(unit.m_camp) && unit.isAlive && unit.m_isVisible)//非我方,活着,可见
                if (unit != _caster)
                {
                    listUnit.Add(unit);
                }
            }
        }

        float minDegree = angleSkill / 2;

        //在大圆范围内的再进行筛选  1.满足选择范围夹角,2.离中心射线夹角最小的
        foreach (var unit in listUnit)
        {
            Vector3 unitVec   = unit.transform.position - skillArrowObj.transform.position;
            Vector3 selectVec = skillArrowObj.transform.forward;
            float   degree    = Vector3.Angle(unitVec, selectVec);
            if (degree <= minDegree)
            {
                minDegree  = degree;
                unitSelect = unit;
            }
        }

        if (unitSelect != null)
        {
            HeadLockSet(true, unitSelect);
        }
        else
        {
            HeadLockSet(false, unitSelect);
        }
        return(unitSelect);
    }
Exemplo n.º 21
0
 public void HeadLockSet(bool active, UnitCtrl unit)
 {
     HeadLockLight.SetActive(active);
     if (active == true)
     {
         HeadLockLight.transform.SetParent(unit.transform);
         HeadLockLight.transform.localPosition = new Vector3(0, 0, 0);
     }
     else
     {
         //_headLockLight.transform.SetParent(m_prefab.transform);
         //_headLockLight.transform.localPosition = new Vector3(0, 0, 0);
     }
 }
Exemplo n.º 22
0
 public void SetButton(UnitCtrl unitCtrl)
 {
     if (buttonType != ButtonType.typeC)
     {
         Debug.LogError("按钮样式错误!");
         return;
     }
     SetButton(unitCtrl.UnitData);
     this.owner           = unitCtrl;
     uIManager            = BattleUIManager.Instance;
     owner.OnChangeState += SetAbnormalIcons;
     SetAbnormalIcons(owner, eStateIconType.NONE, false);
     SetHPAndTP(1, 0);
 }
Exemplo n.º 23
0
    /// <summary>
    /// 플레이어 스폰 메서드
    /// </summary>
    public void SpawnPlayer()
    {
        foreach (PlayerCtrl player in PlayerList)
        {
            Vector3Int spawnPos;
            while (true)
            {
                spawnPos = new Vector3Int(Random.Range(2, GameInfo.nXSize - 2), 0, Random.Range(2, GameInfo.nYSize - 2));

                if (GameMng.Instance.mapMng.bOpen[spawnPos.x, spawnPos.z])
                {
                    break;
                }
            }
            player.spawnPos = spawnPos;
            //플레이어 스폰
            if (player.playerInfo.Type == ePlayerType.Player)
            {
                UnitCtrl unitTemp = null;
                if (player == CtrlPlayer)
                {
                    gameMng.interfaceMng.MainCameraCarrier.localPosition = new Vector3(spawnPos.x, 8, spawnPos.z);
                }
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                gameMng.unitMng.ChangeJob(unitTemp, eUnitJob.Leader);
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
            }
            //컴퓨터 플레이어 스폰
            else if (player.playerInfo.Type == ePlayerType.Computer)
            {
                UnitCtrl unitTemp = null;
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                gameMng.unitMng.ChangeJob(unitTemp, eUnitJob.Leader);

                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                gameMng.unitMng.ChangeJob(unitTemp, eUnitJob.Worker);
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                gameMng.unitMng.ChangeJob(unitTemp, eUnitJob.Worker);
                unitTemp = gameMng.unitMng.CreateUnit(spawnPos, player, eUnitType.People);
                gameMng.unitMng.ChangeJob(unitTemp, eUnitJob.Worker);
            }
            //관전자 스폰
            else
            {
            }
        }
    }
Exemplo n.º 24
0
    public BuildingCtrl CreateBuilding(PlayerCtrl Owner, UnitCtrl Worker, BuildingInfo buildingInfo, Vector3 buildingPos)
    {
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            if (Owner.CurResource(Cost) - buildingInfo.Cost[Cost] < 0)
            {
                gameMng.interfaceMng.AlertText(Cost + "가 부족합니다");
                return(null);
            }
        }
        foreach (string Cost in buildingInfo.Cost.Keys)
        {
            if (Cost == "time")
            {
                continue;
            }
            Owner.UseResource(Cost, buildingInfo.Cost[Cost]);
        }
        GameObject   pre  = Resources.Load("Prefab/" + buildingInfo.Component) as GameObject;
        BuildingCtrl temp = Instantiate(pre, this.transform).GetComponent <BuildingCtrl>();

        temp.SetBuilding(this, buildingInfo, Owner, buildingPos);
        buildingList.Add(temp);

        foreach (MeshRenderer mesh in temp.transform.GetComponentsInChildren <MeshRenderer>())
        {
            if (mesh.transform.tag == "Unit")
            {
                mesh.material = Owner.playerMater;
            }
            if (mesh.transform.tag == "Interface")
            {
                if (Owner == gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[0];
                }
                if (Owner != gameMng.playerMng.CtrlPlayer)
                {
                    mesh.material = RangeMater[1];
                }
            }
        }
        Worker.receiptOrder(new GameSys.Order.Build(temp.Target));
        return(temp);
    }
Exemplo n.º 25
0
        public ActionResult EditUnit(UnitViewModel model)
        {
            string   acc      = "AC003";
            UnitCtrl unitCtrl = new UnitCtrl(acc, model.SID);

            unitCtrl.Unit.UnitName = model.UnitName;
            unitCtrl.Edit();
            var json = new
            {
                unitCtrl.Code,
                unitCtrl.Msg
            };

            return(Json(json, "text/html", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 26
0
        public ActionResult ChangeStatus(string SID, string status)
        {
            string   acc      = "AC003";
            UnitCtrl unitCtrl = new UnitCtrl(acc, SID);

            unitCtrl.Unit.Status = int.Parse(status);
            unitCtrl.ChangeStatus();
            var json = new
            {
                unitCtrl.Code,
                unitCtrl.Msg
            };

            return(Json(json, "text/html", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 27
0
 public bool IsCollisionPos(UnitCtrl self, Vector2 pos)
 {
     foreach (UnitCtrl unit in unitList)
     {
         if (unit == self)
         {
             continue;
         }
         if (Vector2.Distance(unit.Pos, pos) < unit.Stat("Radius") / 2 + self.Stat("Radius") / 2)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 28
0
 public void SetBtn(UnitCtrl myUnit)
 {
     this.myUnit = myUnit;
     if (myUnit == null)
     {
         BtnImage.enabled = false;
         Btn.enabled      = false;
     }
     else
     {
         BtnImage.enabled = true;
         BtnImage.sprite  = Resources.Load <Sprite>("Texture/" + myUnit.Icon);
         Btn.enabled      = true;
     }
 }
Exemplo n.º 29
0
            public override void Works(ObjectCtrl unit)
            {
                UnitCtrl unitCtrl = unit as UnitCtrl;

                if (target != null)
                {
                    if (Vector2.Distance(unitCtrl.Pos, target.Pos) < unitCtrl.Stat("AtkRange"))
                    {
                        unitCtrl.BuildTarget(target);
                    }
                    else
                    {
                        unitCtrl.MoveTarget(target);
                    }
                }
            }
Exemplo n.º 30
0
 public void SetAbnormalIcons(UnitCtrl unitCtrl, eStateIconType stateIconType, bool enable)
 {
     if (stateIconType == eStateIconType.NONE)
     {
         Reflash();
         return;
     }
     if (currentBuffs.Contains(stateIconType))
     {
         currentBuffs.Remove(stateIconType);
     }
     if (enable)
     {
         currentBuffs.Add(stateIconType);
     }
     Reflash();
 }
Exemplo n.º 31
0
 public void EnterBuilding(UnitCtrl enterUnit)
 {
     if (enterUnit.Job != eUnitJob.Worker)
     {
         return;
     }
     if (nEnteredCnt < nEnterMax)
     {
         if (!enteredUnits.Contains(enterUnit))
         {
             RegisterUnit(enterUnit);
         }
         nEnteredCnt++;
         enteredUnits.Add(enterUnit);
         enterUnit.StateChange(eUnitState.Work);
     }
 }
Exemplo n.º 32
0
 public void SwapUnit(CellCtrl curCell)
 {
     UnitCtrl temp = Unit;
     Unit = curCell.Unit;
     curCell.Unit = temp;
 }
Exemplo n.º 33
0
 public void Clear()
 {
     Unit = null;
 }
Exemplo n.º 34
0
 public void SetItem(UnitCtrl item)
 {
     Unit = item;
     Unit.Cell = this;
 }