예제 #1
0
        public sealed override void Attack()
        {
            UnitAnimator.Play("Mushroom_Attack");

            Unit target;

            for (int i = -1; i < 1; i++)
            {
                target = TileManager.Instance.GetContainPlayerUnit(UnitPosition.x + i, UnitPosition.z - 1);
                if (target != null)
                {
                    SporeAttack(target);
                }

                target = TileManager.Instance.GetContainPlayerUnit(UnitPosition.x + i, UnitPosition.z);
                if (target != null)
                {
                    SporeAttack(target);
                }

                target = TileManager.Instance.GetContainPlayerUnit(UnitPosition.x + i, UnitPosition.z + 1);
                if (target != null)
                {
                    SporeAttack(target);
                }
            }
        }
예제 #2
0
    protected void Awake()
    {
        GameManager.Instance.SetPlayer(this);

        rigid = GetComponent <Rigidbody2D>();

        shadow = transform.GetChild(0).gameObject;

        status         = StatusManager.Instance.GetStatus(UnitName);
        status.hp      = 100f;
        status.stamina = 100f;


        state = UnitState.Idle;

        ChildSetting(transform);

        //하위 컴포넌트 초기화
        {
            animator     = GetComponent <UnitAnimator>();
            attack       = GetComponent <UnitAttack>();
            movement     = GetComponent <UnitMovement>();
            colliderctrl = GetComponent <UnitColliderController>();

            animator.ConnectUnit(this);
            attack.ConnectUnit(this);
            movement.ConnectUnit(this);
            colliderctrl.ConnectUnit(this);
        }

        shadow.transform.parent = null;
        StartCoroutine(Shadow());
    }
예제 #3
0
 private void GetComponent()
 {
     gameManager      = FindObjectOfType <GameManager>();
     unitAnimator     = GetComponent <UnitAnimator>();
     unitMove         = GetComponent <UnitMove>();
     statusController = GetComponent <StatusController>();
 }
예제 #4
0
 // 눈 깜박이는 애니메이션 카운트 추가 애니메이터에서 콜백으로 호출
 protected void AddBlinkCount()
 {
     if (UnitAnimator != null)
     {
         UnitAnimator.SetInteger("blink", UnitAnimator.GetInteger("blink") + 1);
     }
 }
 void Start()
 {
     unitController   = GetComponent <UnitController>();
     unitAnimator     = GetComponent <UnitAnimator>();
     unitMove         = GetComponent <UnitMove>();
     statusController = GetComponent <StatusController>();
 }
예제 #6
0
    //awake
    void Start()
    {
        animator     = GetComponentInChildren <UnitAnimator>();
        playerState  = GetComponent <UnitState>();
        rb           = GetComponent <Rigidbody>();
        inputManager = GameObject.FindObjectOfType <InputManager>();

        //assign layers and layermasks
        EnemyLayer             = LayerMask.NameToLayer("Enemy");
        DestroyableObjectLayer = LayerMask.NameToLayer("DestroyableObject");
        EnvironmentLayer       = LayerMask.NameToLayer("Environment");
        HitLayerMask           = (1 << EnemyLayer) | (1 << DestroyableObjectLayer);

        //display error messages for missing components
        if (!animator)
        {
            Debug.LogError("No player animator found inside " + gameObject.name);
        }
        if (!playerState)
        {
            Debug.LogError("No playerState component found on " + gameObject.name);
        }
        if (!rb)
        {
            Debug.LogError("No rigidbody component found on " + gameObject.name);
        }

        //set invulnerable during jump
        if (!invulnerableDuringJump)
        {
            HitableStates.Add(UNITSTATE.JUMPING);
            HitableStates.Add(UNITSTATE.JUMPKICK);
        }
    }
예제 #7
0
    public override void OnEnter()
    {
        unit.Order = Order.OrderNothing();
        //Debug.Log(unit.name + " enters in plaqueState");

        t = 0;
        unit.isTackled = true;
        unit.nma.Stop();

        if (unit == unit.game.Ball.Owner)
        {
            unit.game.Ball.Put();
        }

        if (unit.Team.useColors && unit.Model && unit.Model.renderer)
        {
            foreach (var mat in unit.Model.renderer.materials)
            {
                mat.color = unit.Team.PlaqueColor;
            }
        }

        //if(rotate)
        //    unit.Model.transform.localRotation = Quaternion.Euler(90, 0, 0);

        UnitAnimator ua = unit.unitAnimator;

        if (ua != null)
        {
            ua.Tackled = true;
        }
    }
예제 #8
0
파일: UnitModel.cs 프로젝트: choephix/G11
 public void Init( Unit unit )
 {
     this.animator = GetComponent<UnitAnimator>();
     this.owner = unit;
     this.meshRenderer = renderers[0] as SkinnedMeshRenderer;
     this.materialManager = new UnitMaterialManager( this );
     //this.equiomentHolders = new Holders();
 }
예제 #9
0
    private static void Move(Unit unit)
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Physics.Raycast(ray, out RaycastHit hit, 100);
        unit.AiPath.destination = hit.point;

        UnitAnimator.Move(unit.Animator);
        unit.UnitState = Constants.UnitState.Moving;
        Debug.Log("Move");
    }
예제 #10
0
 public void OnTouchAction()
 {
     foreach (Unit u in units)
     {
         UnitAnimator a = u.unitAnimator;
         if (a != null)
         {
             a.OnTouchAction();
         }
     }
 }
예제 #11
0
 public override void OnUpdate()
 {
     if (!camera_edited && this.game.Ball.Owner != null)
     {
         UnitAnimator ua = this.game.Ball.Owner.unitAnimator;
         if (ua == null || ua.isInState(UnitAnimator.BallIdleState))
         {
             EditCamera();
         }
     }
 }
예제 #12
0
    ////////////////////////여기부터 황비홍 프로젝트 신규 함수
    /// <summary>
    /// 플레이어 생성
    /// </summary>
    /// <param name="parent"></param>
    /// <param name="charIdx"></param>
    /// <param name="HeadItemIdx"></param>
    /// <param name="CostumeItemIdx"></param>
    /// <param name="ClothItemIdx"></param>
    /// <param name="WeaponItemIdx"></param>
    /// <param name="HideCostume"></param>
    /// <returns></returns>
    /// bool isLighting, bool isShadow, bool isRim=true, bool isEff=true
    public static GameObject CreatePcUIModel(string panelName, Transform parent, uint charIdx, uint HeadItemIdx, uint CostumeItemIdx, uint ClothItemIdx, uint WeaponItemIdx, uint skillSetId, byte aniState, bool HideCostume, bool isShadow, bool isWeapon = true)
    {
        if (0 < parent.childCount)
        {
            int count = parent.childCount;
            while (0 < count)
            {
                --count;
                if (parent.GetChild(count).name.Contains("pc"))//혹시모를 예외처리
                {
                    GameObject.Destroy(parent.GetChild(count).gameObject);
                }
            }
        }

        GameObject[] effect   = isWeapon ? new GameObject[2] : null;
        UnitAnimator unitAnim = new UnitAnimator();

        //뻑날때를 대비해 예외처리
        GameObject _unit = UnitModelHelper.PCModelLoadRimSpec(charIdx, HeadItemIdx, CostumeItemIdx, ClothItemIdx, WeaponItemIdx, HideCostume, ref effect, isWeapon);

        //Item.CostumeInfo lowData = _LowDataMgr.instance.GetLowDataCostumeInfo(CostumeItemIdx);

        Resource.AniInfo[] ads = null;

        SkillTables.SkillSetInfo setInfo = _LowDataMgr.instance.GetLowDataSkillSet(skillSetId);
        if (setInfo != null)
        {
            ads = _LowDataMgr.instance.UIAniInfoSetting(setInfo.AniPath, _unit, setInfo.AniId, aniState);
        }

        if (effect != null)//이펙트의 사이즈를 조정해야 하는데 미리 켜져있을 경우 활활 거리는게 있어서 추가함.
        {
            int loopCount = effect.Length;
            for (int i = 0; i < loopCount; i++)
            {
                if (effect[i] != null)
                {
                    effect[i].SetActive(false);
                }
            }
        }

        unitAnim.Init(_unit, _unit.animation, ads);
        unitAnim.Animation.playAutomatically = false;
        unitAnim.PlayAnim(eAnimName.Anim_idle);

        UIModel model = _unit.AddComponent <UIModel>();

        model.Init(parent, unitAnim, effect, charIdx == 13000, isShadow, panelName);

        return(_unit);
    }
예제 #13
0
        private IEnumerator SkeletonAttack()
        {
            UnitAnimator.Play("Skeleton_Attack");

            yield return(new WaitForSeconds(0.2f));

            if (Target != null && Target.HP > 0 && HP > 0)
            {
                SoundManager.Instance.PlaySfx("SkeletonHit", 0.2f);
                GameManager.Instance.EffectSystem.CreateEffect("SlashRed", gameObject.transform.position + new Vector3(0.5f, 0.5f, -0.2f), new Vector3(0.2f, 0.2f, 0.2f), Quaternion.Euler(new Vector3(90, 90, 0)), 2);
                GameManager.Instance.MessageSystem.Publish(DamageEvent.Create(this, Target, CalculateDamage()));
            }
        }
예제 #14
0
    public override bool ExecuteAnimation(SimulatedDisplacement sim, Direction dir, Board board)
    {
        //Clean Up all spawned anims
        foreach (KeyValuePair <Tile, GameObject> pair in ((LancePoke)action).spawnedLanceAnims)
        {
            UnitAnimator animator = pair.Value.GetComponent <UnitAnimator>();
            animator.SetBool("EndAnimation", true);
        }

        //Remove references
        ((LancePoke)action).spawnedLanceAnims.Clear();
        return(true);
    }
예제 #15
0
    private void Start()
    {
        animator         = GetComponentInChildren <UnitAnimator>();
        playerState      = GetComponent <UnitState>();
        playerMovement   = GetComponent <PlayerMovement>();
        rb               = GetComponent <Rigidbody>();
        inputManager     = GameObject.FindObjectOfType <InputManager>();
        currentDirection = DIRECTION.Right;

        enemyLayer             = LayerMask.NameToLayer("Enemy");
        destroyableObjectLayer = LayerMask.NameToLayer("DestroyableObjectLayer");
        hitLayerMask           = (1 << enemyLayer | 1 << destroyableObjectLayer);
    }
예제 #16
0
    public void Initialize(Character character, int rank, Team team)
    {
        EventQueue    = new List <EffectEvent>();
        CombatInfo    = new FormationUnitInfo();
        RectTransform = GetComponent <RectTransform>();
        unitAnimator  = GetComponentInChildren <UnitAnimator>();
        Character     = character;
        Rank          = rank;
        Team          = team;
        OriginalClass = character.Class;

        Character.ApplyAllBuffRules(RaidSceneManager.Rules.GetIdleUnitRules(this));
    }
예제 #17
0
        public sealed override void Init(int HP, int damage,  List<Vector3Int> path) // 필요한 스탯 최대체력 체력 공격력 공격범위, 
        {
            if (UnitAnimator == null)
            {
                UnitAnimator = gameObject.transform.GetChild(0).GetComponent<Animator>();
            }
            else
            {
                UnitAnimator.Rebind();
                UnitAnimator.SetBool("dead", false);
            }

            gameObject.transform.GetChild(0).transform.localPosition = new Vector3(Random.Range(-0.1f, 0.1f), 0.1f, -0.3f + Random.Range(-0.1f, 0.1f));

            unitName = "Kong";

            spriteRenderer = gameObject.gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>();
            spriteRenderer.material.color = new Color(1, 1, 1, 1);

            spriteRenderer.flipX = true;
            monsterTransform = gameObject.transform;

            DamageMultiplier = 1;
            AdditionalDamage = 0;
            MaxHP = HP;
            this.HP = HP;
            Damage = damage;
            AttackDelay = ATTACK_DELAY;
            speed = SPEED;
            CurrentAttackDelay = AttackDelay;

            pathList.Clear();
            foreach (var pos in path)
                pathList.Add(pos);

            this.gameObject.transform.position = pathList[0];
            UnitPosition = pathList[0];

            currentState = MonsterUnitState.SetPath;

            GameManager.Instance.AddUpdate(this);
            GameManager.Instance.MessageSystem.Subscribe(typeof(PlayerUnitSummonEvent), this);
            GameManager.Instance.MessageSystem.Subscribe(typeof(DamageEvent), this);

            for (int i = -2; i < 3; i++)
            {
                rangeTile.Add(new Vector3Int(i, 0, -1));
                rangeTile.Add(new Vector3Int(i, 0, 0));
                rangeTile.Add(new Vector3Int(i, 0, 1));
            }
        }
예제 #18
0
    public void ForDebugWindow()
    {
#if UNITY_EDITOR
        Object [] objs = GameObject.FindObjectsOfType(typeof(UnitAnimator));
        foreach (var o in objs)
        {
            UnitAnimator ua = (UnitAnimator)o;
            bool         isOwner = false, isControlled = false, isTackled = false;
            Color        c = GUI.color;
            if (ua.unit.isOwner())
            {
                isOwner = true;
            }
            if (ua.unit.isTackled)
            {
                isTackled = true;
            }
            if (ua.unit.isControlled())
            {
                isControlled = true;
            }

            if (isOwner)
            {
                GUI.color = Color.cyan;
            }
            else if (isTackled)
            {
                if (isControlled)
                {
                    GUI.color = new Color(1f, 0.54f, 0f);
                }
                else
                {
                    GUI.color = Color.red;
                }
            }
            else if (isControlled)
            {
                GUI.color = Color.yellow;
            }

            EditorGUILayout.ObjectField(o.name, ua.animator, typeof(Animator), true);

            if (isOwner || isControlled || isTackled)
            {
                GUI.color = c;
            }
        }
#endif
    }
예제 #19
0
        // 애니메이터 초기화
        protected void ResetAnimator()
        {
            if (UnitAnimator == null)
            {
                UnitAnimator = this.gameObject.GetComponent <Animator>();
            }
            else
            {
                UnitAnimator.Rebind();
                UnitAnimator.Play("Idle");
            }
            gameObject.transform.GetComponent <SpriteRenderer>().material.color = new Color(1, 1, 1, 1);

            ResetBlinkCount();
        }
예제 #20
0
    public void Initialize(Character character, FormationUnitSaveData saveData)
    {
        EventQueue    = new List <EffectEvent>();
        CombatInfo    = saveData.CombatInfo;
        RectTransform = GetComponent <RectTransform>();
        unitAnimator  = GetComponentInChildren <UnitAnimator>();
        Character     = character;
        if (Character.IsMonster == false)
        {
            Character.LoadStatusEffects(saveData.Statuses);
        }
        Rank          = saveData.Rank;
        Team          = saveData.Team;
        OriginalClass = saveData.OriginalClass;

        Character.ApplyAllBuffRules(RaidSceneManager.Rules.GetIdleUnitRules(this));
    }
예제 #21
0
 public sealed override void Attack()
 {
     if (Target.HP > 0 && CheckMonsterInRange())
     {
         StartCoroutine("AttackRoutine");
         UnitAnimator.SetBool("attack", true);
     }
     else
     {
         UnitAnimator.SetBool("attack", false);
         Target = null;
         if (CheckRangeTileTarget() == false)
         {
             CurrentAttackDelay = AttackDelay;
             currentState       = PlayerUnitState.Idle;
         }
     }
 }
예제 #22
0
    private void Start()
    {
        StartAngularSpeed = navAgent.angularSpeed;
        startAcceleration = navAgent.acceleration;
        startSpeed        = maxSpeed;
        checkTime        += Random.Range(0, 0.2f);

        navAgent     = GetComponent <NavMeshAgent>();
        unitAnimator = gameObject.GetComponent <UnitAnimator>();
        // CreateDetectionCollider();

        InvokeRepeating("AgroUpdateCheck", 0, 2);
        CheckAgro();

        unitCollider = gameObject.GetComponent <Collider>();
        //  UnitHealth target = FunctionsHelper.GetNearestUnit(transform.position, healthScript);
        //   ChaseTarget(target, target.transform);
    }
예제 #23
0
        public override void UpdateFrame(float dt)
        {
            switch (currentState)
            {
            case PlayerUnitState.Init:
                if (CheckRangeTileTarget() == true)
                {
                    currentState = PlayerUnitState.Attack;
                }
                else
                {
                    currentState = PlayerUnitState.Idle;
                }
                break;

            case PlayerUnitState.Idle:
                if (CurrentAttackDelay <= AttackDelay)
                {
                    CurrentAttackDelay += dt;
                }
                break;

            case PlayerUnitState.Attack:
                if (CurrentAttackDelay > AttackDelay)
                {
                    ResetBlinkCount();
                    CurrentAttackDelay = 0;
                    Attack();
                }
                else
                {
                    UnitAnimator.SetBool("attack", false);
                    CurrentAttackDelay += dt;
                }
                break;

            case PlayerUnitState.Dead:
                StartCoroutine("Dead");
                break;

            default:
                break;
            }
        }
예제 #24
0
    // Start is called before the first frame update
    void Start()
    {
        unitManager = GameObject.Find("UnitManager").GetComponent <UnitManager>();

        navMeshAgent = GetComponent <NavMeshAgent>();
        unitAnimator = GetComponent <UnitAnimator>();
        outline      = GetComponent <Outline>();

        if (gameObject.tag == "Friendly")
        {
            enemyTag         = "Enemy";
            enemyBuildingTag = "EnemyBuilding";
        }

        Vector3 pos = transform.position;

        pos.y   += (transform.localScale.y * 2);
        healthUI = Instantiate(healthBarPrefab, pos, Quaternion.identity);
        healthUI.transform.SetParent(transform);
        healthBar = healthUI.transform.Find("foreground").GetComponent <Image>();
        healthUI.SetActive(false);

        if (!melee)
        {
            if (projectilePrefab)
            {
                for (int i = 0; i < 3; i++)
                {
                    GameObject projec = Instantiate(projectilePrefab, transform.position, Quaternion.identity);
                    quiver.Add(projec.GetComponent <Projectile>());
                    projec.gameObject.SetActive(false);
                    projec.transform.SetParent(this.gameObject.transform);
                }
            }
        }

        NewDestination(new Vector3(transform.position.x + UnityEngine.Random.Range(-5, 5), transform.position.y, transform.position.z + UnityEngine.Random.Range(-5, 5)), false);

        if (enemyTag == "Enemy")
        {
            PlayerSkillManager.instance.newUnit(populationValue);
        }
    }
예제 #25
0
        public sealed override IEnumerator Dead()
        {
            Dispose(false);

            GameManager.Instance.MessageSystem.Publish(PlayerUnitDeadEvent.Create(UnitPosition, this));
            UnitAnimator.SetBool("dead", true);
            yield return(new WaitForSeconds(1f));

            float alpha = gameObject.transform.GetComponent <SpriteRenderer>().material.color.a;

            for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / 1)
            {
                Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 0, t));
                transform.GetComponent <SpriteRenderer>().material.color = newColor;
                yield return(null);
            }
            UnitAnimator.SetBool("dead", false);
            FieldObjectManager.Instance.ReleaseUnit(unitName, this);
        }
예제 #26
0
    void Update()
    {
        if (Input.GetMouseButtonDown(Constants.RightMouseButton))
        {
            Move(this);
        }

        if (AiPath.remainingDistance < 2f && UnitState != Constants.UnitState.Idle)
        {
            UnitAnimator.Idle(Animator);
            UnitState = Constants.UnitState.Idle;
            Debug.Log("Stop");
        }

        if (AiPath.remainingDistance >= 2f && UnitState != Constants.UnitState.Moving)
        {
            UnitAnimator.Move(Animator);
            UnitState = Constants.UnitState.Moving;
            Debug.Log("Moving");
        }
    }
예제 #27
0
    //[SyncVar(hook = "OnChangeHealth")]

    void Start()
    {
        currentHealth = maxHealth;
        animator      = GetComponent <UnitAnimator>();
        if (animator == null)
        {
            Debug.LogError("No unit animator attatched to health script");
        }

        unitScript = GetComponent <Unit>();

        StartCoroutine(healthRegen());

        if (InstantiateSliderOnStartup == true)
        {
            GameObject SliderClone = (GameObject)Instantiate(SliderPrefab, SliderPosition.position, SliderPosition.rotation, SliderPosition);
            slider          = SliderClone.GetComponentInChildren <Slider>();
            slider.maxValue = maxHealth;
            slider.value    = currentHealth;
            SliderPrefab    = SliderClone;
        }
    }
예제 #28
0
    void Start()
    {
        //find components
        if (!animator)
        {
            animator = GetComponentInChildren <UnitAnimator>();
        }
        if (!rb)
        {
            rb = GetComponent <Rigidbody>();
        }
        if (!playerState)
        {
            playerState = GetComponent <UnitState>();
        }
        if (!capsule)
        {
            capsule = GetComponent <CapsuleCollider>();
        }

        //error messages for missing components
        if (!animator)
        {
            Debug.LogError("No animator found inside " + gameObject.name);
        }
        if (!rb)
        {
            Debug.LogError("No Rigidbody component found on " + gameObject.name);
        }
        if (!playerState)
        {
            Debug.LogError("No UnitState component found on " + gameObject.name);
        }
        if (!capsule)
        {
            Debug.LogError("No Capsule Collider found on " + gameObject.name);
        }
    }
예제 #29
0
        public sealed override IEnumerator Dead()
        {
            Dispose(false);

            GameManager.Instance.MessageSystem.Publish(MonsterDeadEvent.Create(this, UnitPosition));
            UnitAnimator.SetBool("dead", true);
            yield return(new WaitForSeconds(0.2f));

            GameManager.Instance.EffectSystem.CreateEffect("DeathStandard", this.gameObject.transform.position + new Vector3(0, 0.1f, -0.1f), new Vector3(0.25f, 0.25f, 0.25f), Quaternion.Euler(new Vector3(-90, 0, 0)), 2);
            SoundManager.Instance.PlaySfx("Weird0" + Random.Range(1, 5), 0.1f);
            yield return(new WaitForSeconds(0.1f));

            float alpha = spriteRenderer.material.color.a;

            for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / 1)
            {
                Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha, 0, t));
                spriteRenderer.material.color = newColor;
                yield return(null);
            }
            UnitAnimator.SetBool("dead", false);
            FieldObjectManager.Instance.ReleaseUnit(unitName, this);
        }
예제 #30
0
    public override void OnLeave()
    {
        unit.isTackled = false;

        if (unit.Team.useColors && unit.Model && unit.Model.renderer)
        {
            foreach (var mat in unit.Model.renderer.materials)
            {
                mat.color = unit.Team.Color;
            }
        }

        //if(rotate)
        //    unit.Model.transform.localRotation = Quaternion.identity;

        UnitAnimator ua = unit.unitAnimator;

        if (ua != null)
        {
            ua.Tackling = false;
            ua.Tackled  = false;
        }
    }
예제 #31
0
    private void Start()
    {
        if (!animator)
        {
            animator = GetComponentInChildren <UnitAnimator>();
        }
        if (!rb)
        {
            rb = GetComponent <Rigidbody>();
        }
        if (!playerState)
        {
            playerState = GetComponent <UnitState>();
        }
        if (!capsule)
        {
            capsule = GetComponent <CapsuleCollider>();
        }

        if (!animator)
        {
            Debug.LogError("No animator found inside" + gameObject.name);
        }
        if (!rb)
        {
            Debug.LogError("No rigidbody component found on " + gameObject.name);
        }
        if (!playerState)
        {
            Debug.LogError("No UnitState component found on " + gameObject.name);
        }
        if (!capsule)
        {
            Debug.LogError("No Capsule Collider found on " + gameObject.name);
        }
        currentDirection = DIRECTION.Right;
    }
예제 #32
0
파일: Unit.cs 프로젝트: choephix/G11
	/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/

	void Awake() {

		relations = new UnitUnitRelations( this );

		animator = GetComponent<UnitAnimator>();

		actions.Init( this );

		Action action;
		action = new ActionsBook.Move( this, this );
		actions += action;
		actions.defaultAction = action;

		action = new ActionsBook.Crouch( this );
		actions += action;

		action = new ActionsBook.Defend( this, this );
		actions += action;

		action = new ActionsBook.Test( this );
		actions += action;

	}